<!DOCTYPE html>
<html lang="zh" dir="ltr">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Camunda SpringBoot与进阶内容 – 邵晨峰的博客</title>
    


  
  <script defer src="/js/fuse.min.c4bee9a8d44273d6154fe86006923d4131eb2e8069d8897687137c6f37f553e3.js"></script>



<script src="/js/enquire.min.aa37bdcb743826eecdae5c5d177fc7d6552340f1b4378ffaa9c82b2c6111400b.js"></script>

<script defer src="/js/lazysizes.min.5e11d056075a05065b9c0bfec44084a113fc2976c2952ec804dedb61c7662db9.js"></script>

<script defer src="/js/helper/getParents.min.ccd45f158c1b17849307ba913a72beac239c410f2b6e648496a79842da84e55b.js"></script>

<script defer src="/js/helper/fadeinout.min.9fb19682560d5fa5596fffec85da605067c4acc86aad05add4d8fff9d362a446.js"></script>

<script>
  "use strict";
  
  
  var targetProtocol = "http:"; 
  if (window.location.protocol != targetProtocol)
    window.location.href = targetProtocol + window.location.href.substring(window.location.protocol.length);

  
  function baiduSearch(event) {
    var evt = window.event || event;
        if (evt.keyCode == 13) {
          console.log(event)
          var val = document.getElementById("search").value
          if(!val){
                  alert('搜索内容为空，请输入');
                  return false;
          }else{
            val = val + " site:shaochenfeng.com"
            window.open("https://www.baidu.com/s?ie=utf-8&wd=" + val);
          }
        }
  }

  window.onload = function() {
    
    var languagedir = JSON.parse("\"ltr\"");
    
    var baseurl = JSON.parse("\"http://shaochenfeng.com\"");
    
    var permalink = JSON.parse("\"http://shaochenfeng.com/camunda/camunda-springboot%E4%B8%8E%E8%BF%9B%E9%98%B6%E5%86%85%E5%AE%B9/\"");

    
    var toggleSidebarElem = document.getElementById("toggle-sidebar");
    var toggleMenuElem = document.getElementById("toggle-menu");
    var tocBodyElem = document.querySelector('.toc__body');
    var tocLabelElem = document.querySelector('.toc__label');
    var listMainElem = document.getElementById('list-main');
    var listSideElem = document.getElementById('list-side');
    var singleMenuElem = document.getElementById('single-menu');
    var sliderIcons = document.querySelectorAll('.slider__icon');

    toggleSidebarElem ?
      toggleSidebarElem.addEventListener('change', function (e) {
        if (e.target.checked) {
          if (tocBodyElem) {
            fadeIn(tocBodyElem, 200);
          }
          if (tocLabelElem) {
            fadeIn(tocLabelElem, 200);
          }
          if (listMainElem && listSideElem) {
            listMainElem.className = 'm';
            listSideElem.className = 'r';
          }

          sliderIcons && sliderIcons.forEach(function (elem) {
            if (elem.classList.contains('hide')) {
              elem.classList.remove('hide');
            } else {
              elem.classList.add('hide');
            }
          });

        } else {
          if (tocBodyElem) {
            fadeOut(tocBodyElem, 200);
          }
          if (tocLabelElem) {
            fadeOut(tocLabelElem, 200);
          }
          if (listMainElem && listSideElem) {
            listMainElem.className = 'mr';
            listSideElem.className = 'hide';
          }

          sliderIcons && sliderIcons.forEach(function (elem) {
            if (elem.classList.contains('hide')) {
              elem.classList.remove('hide');
            } else {
              elem.classList.add('hide');
            }
          });
        }
      }) : null;

    toggleMenuElem ?
      toggleMenuElem.addEventListener('change', function (e) {
        if (e.target.checked) {
          if (listMainElem && singleMenuElem) {
            listMainElem.className = 'm';
            singleMenuElem.className = 'l';
          }

          sliderIcons && sliderIcons.forEach(function (elem) {
            if (elem.classList.contains('hide')) {
              elem.classList.remove('hide');
            } else {
              elem.classList.add('hide');
            }
          });

        } else {
          if (listMainElem && singleMenuElem) {
            listMainElem.className = 'lm';
            singleMenuElem.className = 'hide';
          }

          sliderIcons && sliderIcons.forEach(function (elem) {
            if (elem.classList.contains('hide')) {
              elem.classList.remove('hide');
            } else {
              elem.classList.add('hide');
            }
          });
        }
      }) : null;
    


    
    var navCollapseBtn = document.getElementById('navCollapseBtn');
    navCollapseBtn ? navCollapseBtn.addEventListener('click', function(e) {
      var navCollapse = document.querySelector('.navbar__collapse');
      
      if (navCollapse) {
        var dataOpen = navCollapse.getAttribute('data-open');

        if (dataOpen === 'true') {
          navCollapse.setAttribute('data-open', 'false');
          navCollapse.style.maxHeight = 0;
        } else {
          navCollapse.setAttribute('data-open', 'true');
          navCollapse.style.maxHeight = navCollapse.scrollHeight + "px";
        }
      }
    }) : null;
    


    
    var expandBtn = document.querySelectorAll('.expand__button');

    for (let i = 0; i < expandBtn.length; i++) {
      expandBtn[i].addEventListener("click", function () {
        var content = this.nextElementSibling;
        if (content.style.maxHeight) {
          content.style.maxHeight = null;
          this.querySelector('svg').classList.add('expand-icon__right');
          this.querySelector('svg').classList.remove('expand-icon__down');
        } else {
          content.style.maxHeight = content.scrollHeight + "px";
          this.querySelector('svg').classList.remove('expand-icon__right');
          this.querySelector('svg').classList.add('expand-icon__down');
        }
      });
    }
    



    
    document.querySelectorAll('.tab') ? 
    document.querySelectorAll('.tab').forEach(function(elem, idx) {
      var containerId = elem.getAttribute('id');
      var containerElem = elem;
      var tabLinks = elem.querySelectorAll('.tab__link');
      var tabContents = elem.querySelectorAll('.tab__content');
      var ids = [];

      tabLinks && tabLinks.length > 0 ?
      tabLinks.forEach(function(link, index, self) {
        link.onclick = function(e) {
          for (var i = 0; i < self.length; i++) {
            if (index === parseInt(i, 10)) {
              if (!self[i].classList.contains('active')) {
                self[i].classList.add('active');
                tabContents[i].style.display = 'block';
              }
            } else {
              self[i].classList.remove('active');
              tabContents[i].style.display = 'none';
            }
          }
        }
      }) : null;
    }) : null;
    


    
    document.querySelectorAll('.codetab') ? 
    document.querySelectorAll('.codetab').forEach(function(elem, idx) {
      var containerId = elem.getAttribute('id');
      var containerElem = elem;
      var codetabLinks = elem.querySelectorAll('.codetab__link');
      var codetabContents = elem.querySelectorAll('.codetab__content');
      var ids = [];

      codetabLinks && codetabLinks.length > 0 ?
      codetabLinks.forEach(function(link, index, self) {
        link.onclick = function(e) {
          for (var i = 0; i < self.length; i++) {
            if (index === parseInt(i, 10)) {
              if (!self[i].classList.contains('active')) {
                self[i].classList.add('active');
                codetabContents[i].style.display = 'block';
              }
            } else {
              self[i].classList.remove('active');
              codetabContents[i].style.display = 'none';
            }
          }
        }
      }) : null;
    }) : null;
    

    
    
    
    var enableDarkMode = JSON.parse("true");
    var root = document.getElementById('root');
    var toggleToLightBtn = document.getElementById('toggleToLight');
    var toggleToDarkBtn = document.getElementById('toggleToDark');

    if (!enableDarkMode) {
      root.className = 'theme__light';
      localStorage.setItem('theme', 'light');
    }
    
    if (toggleToDarkBtn) {
      toggleToDarkBtn.onclick = function (e) {
        root.className = 'theme__dark';
        localStorage.setItem('theme', 'dark');
        toggleToLightBtn.className = 'navbar__icons--icon';
        toggleToDarkBtn.className = 'hide';
      }
    }

    if (toggleToLightBtn) {
      toggleToLightBtn.onclick = function (e) {
        root.className = 'theme__light';
        localStorage.setItem('theme', 'light');
        toggleToLightBtn.className = 'hide';
        toggleToDarkBtn.className = 'navbar__icons--icon';
      }
    }

    
    document.querySelectorAll('.menu__list').forEach(function(elem) {
      if (elem.classList.contains('active')) {
        elem.style.maxHeight = elem.scrollHeight + "px"; 
      }
    });
    
    document.querySelectorAll('.menu__title--collapse').forEach(function(elem) {
      elem.addEventListener('click', function (e) {
        var content = this.nextElementSibling;
        var menuTitleIcon = this.querySelector('.menu__title--icon');
        if (!content) {
          return null;
        }

        var parent = elem.parentNode;
        while (parent.classList.contains('menu__list') && parent.classList.contains('active')) {
          parent.style.maxHeight = 100 * parent.children.length + "px";
          parent = parent.parentNode;
        }

        if (content.style.maxHeight) {
          content.style.maxHeight = null;
          content.classList.remove('active');
          menuTitleIcon.classList.add('right');
          
          if (languagedir === 'rtl') {
            menuTitleIcon.classList.remove('downrtl');
          } else {
            menuTitleIcon.classList.remove('down');
          }
        } else {
          content.style.maxHeight = content.scrollHeight + "px";
          content.classList.add('active');
          menuTitleIcon.classList.remove('right');
          
          if (languagedir === 'rtl') {
            menuTitleIcon.classList.add('downrtl');
          } else {
            menuTitleIcon.classList.add('down');
          }
        }
      });
    });
    


    
    var mobileLogo = document.getElementById('mobileLogo');
    var modal = document.getElementById("myModal");
    var drawer = document.getElementById('myDrawer');
    var drawerCloseBtn = document.querySelector('.drawer__close');

    var openDrawer = function() {
      modal.style.opacity = 1;

      if (languagedir === 'rtl') {
        modal.style.right = 0;
        drawer.style.right = 0;
      } else {
        modal.style.left = 0;
        drawer.style.left = 0;
      }
    }

    var closeDrawer = function() {
      modal.style.opacity = 0;

      if (languagedir === 'rtl') {
        drawer.style.right = '-100%';
      } else {
        drawer.style.left = '-100%';
      }

      
      setTimeout(function () {
        if (languagedir === 'rtl') {
          modal.style.right = '-100%';
        } else {
          modal.style.left = '-100%';
        }
      }, 250);
    }

    mobileLogo.onclick = function () {
      openDrawer();
      localStorage.setItem('isDrawerOpen', 'true');
    }

    modal.onclick = function () {
      closeDrawer();
      localStorage.setItem('isDrawerOpen', 'false');
    }

    drawerCloseBtn.onclick = function () {
      closeDrawer();
      localStorage.setItem('isDrawerOpen', 'false');
    }
  


  
    var lastScrollTop = window.pageYOffset || document.documentElement.scrollTop;
    var tocElem = document.querySelector('.toc');
    var tableOfContentsElem = tocElem ? tocElem.querySelector('#TableOfContents') : null;
    var singleContentsElem = document.querySelector('.single__contents');
    var dataBGImgs = document.querySelectorAll('div[data-bgimg]');

    
    var tocLevels = JSON.parse("null");

    if (tocLevels) {
      tocLevels = tocLevels.toString();
    } else {
      tocLevels = "h1, h2, h3, h4, h5, h6";
    }

    
    var isLandingBgImg = JSON.parse("null");
    
    var isHome = JSON.parse("false");

    function setNavbarBG(scrollTop) {
      if (isHome && isLandingBgImg && Object.keys(isLandingBgImg).length) {
        if (isLandingBgImg.height <= scrollTop) {
          dataBGImgs.forEach(function(elem) {
            elem.setAttribute('data-bgimg', 'false');
          });
        } else {
          dataBGImgs.forEach(function (elem) {
            elem.setAttribute('data-bgimg', 'true');
          });
        }
      }
    }
    setNavbarBG(lastScrollTop);

    window.onscroll = function () {
      var st = window.pageYOffset || document.documentElement.scrollTop;
      if (st > lastScrollTop) { 
        singleContentsElem ? 
        singleContentsElem.querySelectorAll(tocLevels.toString()).forEach(function(elem) {
          if (document.documentElement.scrollTop >= elem.offsetTop) {
            if (tableOfContentsElem) {
              var id = elem.getAttribute('id');
              tocElem.querySelectorAll('a').forEach(function (elem) {
                elem.classList.remove('active');
              });
              tocElem.querySelector('a[href="#' + id + '"]') ? 
              tocElem.querySelector('a[href="#' + id + '"]').classList.add('active') : null;
            }
          }
        }) : null;
        setNavbarBG(st);
      } else { 
        singleContentsElem ? 
        singleContentsElem.querySelectorAll(tocLevels.toString()).forEach(function(elem) {
          if (document.documentElement.scrollTop >= elem.offsetTop) {
            if (tableOfContentsElem) {
              var id = elem.getAttribute('id');
              tocElem.querySelectorAll('a').forEach(function (elem) {
                elem.classList.remove('active');
              });
              tocElem.querySelector('a[href="#' + id + '"]') ? 
              tocElem.querySelector('a[href="#' + id + '"]').classList.add('active') : null;
            }
          }
        }) : null;
        setNavbarBG(st);
      }
      lastScrollTop = st <= 0 ? 0 : st;
    };
    



    
    var mobileSearchInputElem = document.querySelector('#search-mobile');
    var mobileSearchClassElem = document.querySelector('.mobile-search');
    var mobileSearchBtnElem = document.querySelector('#mobileSearchBtn');
    var mobileSearchCloseBtnElem = document.querySelector('#search-mobile-close');
    var mobileSearchContainer = document.querySelector('#search-mobile-container');
    var mobileSearchResultsElem = document.querySelector('#search-mobile-results');
    var htmlElem = document.querySelector('html');

    if (mobileSearchClassElem) {
      mobileSearchClassElem.style.display = 'none';
    }

    mobileSearchBtnElem ? 
    mobileSearchBtnElem.addEventListener('click', function () {
      if (mobileSearchContainer) {
        mobileSearchContainer.style.display = 'block';
      }

      if (mobileSearchInputElem) {
        mobileSearchInputElem.focus();
      }

      if (htmlElem) {
        htmlElem.style.overflowY = 'hidden';
      }
    }) : null;

    mobileSearchCloseBtnElem ? 
    mobileSearchCloseBtnElem.addEventListener('click', function() {
      if (mobileSearchContainer) {
        mobileSearchContainer.style.display = 'none';
      }

      if (mobileSearchInputElem) {
        mobileSearchInputElem.value = '';
      }
      
      if (mobileSearchResultsElem) {
        while (mobileSearchResultsElem.firstChild) {
          mobileSearchResultsElem.removeChild(mobileSearchResultsElem.firstChild);
        }
      }

      if (htmlElem) {
        htmlElem.style.overflowY = 'visible';
      }
    }) : null;

    mobileSearchInputElem ? 
    mobileSearchInputElem.addEventListener('keydown', function(e) {
      if (e.key === 'Escape') {
        if (mobileSearchContainer) {
          mobileSearchContainer.style.display = 'none';
        }
        
        if (mobileSearchInputElem) {
          mobileSearchInputElem.value = '';
        }

        if (mobileSearchResultsElem) {
          while (mobileSearchResultsElem.firstChild) {
            mobileSearchResultsElem.removeChild(mobileSearchResultsElem.firstChild);
          }
        }
        if (htmlElem) {
          htmlElem.style.overflowY = 'visible';
        }
      }
    }) : null;
  


  
    var localTheme = localStorage.getItem('theme');
    var rootEleme = document.getElementById('root');
    var selectThemeElem = document.querySelectorAll('.select-theme');
    var selectThemeItemElem = document.querySelectorAll('.select-theme__item');
    
    if (localTheme) {
      selectThemeItemElem ? 
      selectThemeItemElem.forEach(function (elem) {
        if (elem.text.trim() === localTheme) {
          elem.classList.add('is-active');
        } else {
          elem.classList.remove('is-active');
        }
      }) : null;
    }

    selectThemeItemElem ? 
    selectThemeItemElem.forEach(function (v, i) {
      v.addEventListener('click', function (e) {
        var selectedThemeVariant = e.target.text.trim();
        localStorage.setItem('theme', selectedThemeVariant);

        rootEleme.removeAttribute('class');
        rootEleme.classList.add(`theme__${selectedThemeVariant}`);
        selectThemeElem.forEach(function(rootElem) {
          rootElem.querySelectorAll('a').forEach(function (elem) {
            if (elem.classList) {
              if (elem.text.trim() === selectedThemeVariant) {
                if (!elem.classList.contains('is-active')) {
                  elem.classList.add('is-active');
                }
              } else {
                if (elem.classList.contains('is-active')) {
                  elem.classList.remove('is-active');
                }
              }
            }
          });
        });

        if (window.mermaid) {
          if (selectedThemeVariant === "dark" || selectedThemeVariant === "hacker") {
            mermaid.initialize({ theme: 'dark' });
            location.reload();
          } else {
            mermaid.initialize({ theme: 'default' });
            location.reload();
          }
        }

        var utterances = document.querySelector('iframe');
        if (utterances) {
          utterances.contentWindow.postMessage({
            type: 'set-theme',
            theme: selectedThemeVariant === "dark" || selectedThemeVariant === "hacker" ? 'photon-dark' : selectedThemeVariant === 'kimbie' ? 'github-dark-orange' : 'github-light',
          }, 'https://utteranc.es');
        }
      });
    }) : null;
  


  
    
    var langprefix = JSON.parse("\"\"");
    var searchResults = null;
    var searchMenu = null;
    var searchText = null;
    
    
    var enableSearchHighlight = JSON.parse("null");
    
    var enableSearch = JSON.parse("true");

    var fuse = null;

    if (enableSearch) {
      (function initFuse() {
        var xhr = new XMLHttpRequest();
        xhr.open('GET', baseurl + langprefix + "/index.json");
        xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
        xhr.onload = function () {
          if (xhr.status === 200) {
            fuse = new Fuse(JSON.parse(xhr.response.toString('utf-8')), {
              keys: ['title', 'description', 'content'],
              includeMatches: enableSearchHighlight,
              shouldSort: true,
              threshold: 0.4,
              location: 0,
              distance: 100,
              maxPatternLength: 32,
              minMatchCharLength: 1,
            });
          }
          else {
            console.error(`[${xhr.status}]Error:`, xhr.statusText);
          }
        };
        xhr.send();
      })();
    }
    
    function makeLi(ulElem, obj) {
      var li = document.createElement('li');
      li.className = 'search-result__item';
      
      var a = document.createElement('a');
      a.innerHTML = obj.title;
      a.setAttribute('class', 'search-result__item--title');
      a.setAttribute('href', obj.permalink);

      var descDiv = document.createElement('div');
      descDiv.setAttribute('class', 'search-result__item--desc');
      if (obj.description) {
        descDiv.innerHTML = obj.description.substring(0, 80);
      } else if (obj.content) {
        descDiv.innerHTML = obj.content.substring(0, 80);
      }
      
      li.appendChild(a);
      li.appendChild(descDiv);
      ulElem.appendChild(li);
    }

    function makeHighlightLi(ulElem, obj) {
      var li = document.createElement('li');
      li.className = 'search-result__item';
      var descDiv = null;

      var a = document.createElement('a');
      a.innerHTML = obj.item.title;
      a.setAttribute('class', 'search-result__item--title');
      a.setAttribute('href', obj.item.uri);

      if (obj.matches && obj.matches.length) {
        for (var i = 0; i < obj.matches.length; i++) {
          if ('title' === obj.matches[i].key) {
            a = document.createElement('a');
            a.innerHTML = generateHighlightedText(obj.matches[i].value, obj.matches[i].indices);
            a.setAttribute('class', 'search-result__item--title');
            a.setAttribute('href', obj.item.uri);
          }
          
          if ('description' === obj.matches[i].key) {
            descDiv = document.createElement('div');
            descDiv.setAttribute('class', 'search-result__item--desc');
            descDiv.innerHTML = generateHighlightedText(obj.item.description, obj.matches[i].indices);
          } else if ('content' === obj.matches[i].key) {
            if (!descDiv) {
              descDiv = document.createElement('div');
              descDiv.setAttribute('class', 'search-result__item--desc');
              descDiv.innerHTML = generateHighlightedText(obj.item.content.substring(0, 80), obj.matches[i].indices);
            }
          } else {
            if (obj.item.description) {
              descDiv = document.createElement('div');
              descDiv.setAttribute('class', 'search-result__item--desc');
              descDiv.innerHTML = obj.item.description;
            } else {
              descDiv = document.createElement('div');
              descDiv.setAttribute('class', 'search-result__item--desc');
              descDiv.innerHTML = obj.item.content.substring(0, 80);
            }
          }
        }

        li.appendChild(a);
        if (descDiv) {
          li.appendChild(descDiv);
        }
        if (li) {
          ulElem.appendChild(li);
        }
      }
    }

    function renderSearchResults(searchText, results) {
      searchResults = document.getElementById('search-results');
      searchMenu = document.getElementById('search-menu');
      searchResults.setAttribute('class', 'dd is-active');
      
      var ul = document.createElement('ul');
      ul.setAttribute('class', 'dd-content search-content');

      if (results.length) {
        results.forEach(function (result) {
          var li = document.createElement('li');
          var a = document.createElement('a');
          a.setAttribute('href', result.uri);
          a.setAttribute('class', 'dd-item');
          a.appendChild(li);

          var titleDiv = document.createElement('div');
          titleDiv.innerHTML = result.title;
          titleDiv.setAttribute('class', 'search-result__item--title');

          var descDiv = document.createElement('div');
          descDiv.setAttribute('class', 'search-result__item--desc');
          if (result.description) {
            descDiv.innerHTML = result.description;
          } else if (result.content) {
            descDiv.innerHTML = result.content.substring(0, 80);
          }

          li.appendChild(titleDiv);
          li.appendChild(descDiv);
          ul.appendChild(a);
        });
      } else {
        var li = document.createElement('li');
        li.setAttribute('class', 'dd-item');
        li.innerText = 'No results found';
        ul.appendChild(li);
      }

      while (searchMenu.hasChildNodes()) {
        searchMenu.removeChild(
          searchMenu.lastChild
        );
      }
      
      searchMenu.appendChild(ul);
    }

    function renderSearchHighlightResults(searchText, results) {
      searchResults = document.getElementById('search-results');
      searchMenu = document.getElementById('search-menu');
      searchResults.setAttribute('class', 'dd is-active');

      var ul = document.createElement('ul');
      ul.setAttribute('class', 'dd-content search-content');

      if (results.length) {
        results.forEach(function (result) {
          var li = document.createElement('li');
          var a = document.createElement('a');
          var descDiv = null;

          a.setAttribute('href', result.item.uri);
          a.setAttribute('class', 'dd-item');
          a.appendChild(li);

          var titleDiv = document.createElement('div');
          titleDiv.innerHTML = result.item.title;
          titleDiv.setAttribute('class', 'search-result__item--title');
          
          if (result.matches && result.matches.length) {
            for (var i = 0; i < result.matches.length; i++) {
              if ('title' === result.matches[i].key) {
                titleDiv.innerHTML = generateHighlightedText(result.matches[i].value, result.matches[i].indices);
              }

              if ('description' === result.matches[i].key) {
                descDiv = document.createElement('div');
                descDiv.setAttribute('class', 'search-result__item--desc');
                descDiv.innerHTML = generateHighlightedText(result.item.description, result.matches[i].indices);
              } else if ('content' === result.matches[i].key) {
                if (!descDiv) {
                  descDiv = document.createElement('div');
                  descDiv.setAttribute('class', 'search-result__item--desc');
                  descDiv.innerHTML = generateHighlightedText(result.item.content.substring(0, 80), result.matches[i].indices);
                }
              } else {
                if (result.item.description) {
                  descDiv = document.createElement('div');
                  descDiv.setAttribute('class', 'search-result__item--desc');
                  descDiv.innerHTML = result.item.description;
                } else {
                  descDiv = document.createElement('div');
                  descDiv.setAttribute('class', 'search-result__item--desc');
                  descDiv.innerHTML = result.item.content.substring(0, 80);
                }
              }
            }
            
            li.appendChild(titleDiv);
            if (descDiv) {
              li.appendChild(descDiv);
            }
            ul.appendChild(a);
          }
        });
      } else {
        var li = document.createElement('li');
        li.setAttribute('class', 'dd-item');
        li.innerText = 'No results found';
        ul.appendChild(li);
      }

      while (searchMenu.hasChildNodes()) {
        searchMenu.removeChild(
          searchMenu.lastChild
        );
      }
      searchMenu.appendChild(ul);
    }

    function renderSearchResultsMobile(searchText, results) {
      searchResults = document.getElementById('search-mobile-results');

      var content = document.createElement('div');
      content.setAttribute('class', 'mobile-search__content');

      if (results.length > 0) {
        results.forEach(function (result) {
          var item = document.createElement('a');
          item.setAttribute('href', result.uri);
          item.innerHTML = '<div class="mobile-search__item"><div class="mobile-search__item--title">📄 ' +
             result.title + '</div><div class="mobile-search__item--desc">' + 
               (result.description ? result.description.substring(0,40) : result.content.substring(0,40)) +
                '</div></div>';
          content.appendChild(item);
        });
      } else {
        var item = document.createElement('span');
        content.appendChild(item);
      }

      let wrap = document.getElementById('search-mobile-results');
      while (wrap.firstChild) {
        wrap.removeChild(wrap.firstChild)
      }
      searchResults.appendChild(content);      
    }

    function renderSearchHighlightResultsMobile(searchText, results) {
      searchResults = document.getElementById('search-mobile-results');

      var ul = document.createElement('div');
      ul.setAttribute('class', 'mobile-search__content');

      if (results.length) {
        results.forEach(function (result) {
          var li = document.createElement('li');
          var a = document.createElement('a');
          var descDiv = null;

          a.setAttribute('href', result.item.uri);
          a.appendChild(li);
          li.setAttribute('class', 'mobile-search__item');

          var titleDiv = document.createElement('div');
          titleDiv.innerHTML = result.item.title;
          titleDiv.setAttribute('class', 'mobile-search__item--title');
          
          if (result.matches && result.matches.length) {
            for (var i = 0; i < result.matches.length; i++) {
              if ('title' === result.matches[i].key) {
                titleDiv.innerHTML = generateHighlightedText(result.matches[i].value, result.matches[i].indices);
              }

              if ('description' === result.matches[i].key) {
                descDiv = document.createElement('div');
                descDiv.setAttribute('class', 'mobile-search__item--desc');
                descDiv.innerHTML = generateHighlightedText(result.item.description, result.matches[i].indices);
              } else if ('content' === result.matches[i].key) {
                if (!descDiv) {
                  descDiv = document.createElement('div');
                  descDiv.setAttribute('class', 'mobile-search__item--desc');
                  descDiv.innerHTML = generateHighlightedText(result.item.content.substring(0, 150), result.matches[i].indices);
                }
              } else {
                if (result.item.description) {
                  descDiv = document.createElement('div');
                  descDiv.setAttribute('class', 'mobile-search__item--desc');
                  descDiv.innerHTML = result.item.description;
                } else {
                  descDiv = document.createElement('div');
                  descDiv.setAttribute('class', 'mobile-search__item--desc');
                  descDiv.innerHTML = result.item.content.substring(0, 150);
                }
              }
            }
            
            li.appendChild(titleDiv);
            if (descDiv) {
              li.appendChild(descDiv);
            }
            ul.appendChild(a);
          }
        });
      } else {
        var item = document.createElement('span');
        ul.appendChild(item);
      }

      let wrap = document.getElementById('search-mobile-results');
      while (wrap.firstChild) {
        wrap.removeChild(wrap.firstChild)
      }
      searchResults.appendChild(ul);
    }

    function generateHighlightedText(text, regions) {
      if (!regions) {
        return text;
      }

      var content = '', nextUnhighlightedRegionStartingIndex = 0;

      regions.forEach(function(region) {
        if (region[0] === region[1]) {
          return null;
        }
        
        content += '' +
          text.substring(nextUnhighlightedRegionStartingIndex, region[0]) +
          '<span class="search__highlight">' +
            text.substring(region[0], region[1] + 1) +
          '</span>' +
        '';
        nextUnhighlightedRegionStartingIndex = region[1] + 1;
      });

      content += text.substring(nextUnhighlightedRegionStartingIndex);

      return content;
    };

    var searchElem = document.getElementById('search');
    var searchMobile = document.getElementById('search-mobile');
    var searchResultsContainer = document.getElementById('search-results');

    searchElem ? 
    searchElem.addEventListener('input', function(e) {
      if (!e.target.value | window.innerWidth < 770) {
        searchResultsContainer ? searchResultsContainer.setAttribute('class', 'dd') : null;
        return null;
      }

      searchText = e.target.value;
      var results = fuse.search(e.target.value);

      if (enableSearchHighlight) {
        renderSearchHighlightResults(searchText, results);
      } else {
        renderSearchResults(searchText, results);
      }

      var dropdownItems = searchResultsContainer.querySelectorAll('.dd-item');
      dropdownItems ? dropdownItems.forEach(function (item) {
        item.addEventListener('mousedown', function (e) {
          e.target.click();
        });
      }) : null;
    }) : null;

    searchElem ? 
    searchElem.addEventListener('blur', function() {
      if (window.innerWidth < 770) {
        return null;
      }
      searchResultsContainer ? searchResultsContainer.setAttribute('class', 'dd') : null;
    }) : null;

    searchElem ? 
    searchElem.addEventListener('click', function(e) {
      if (window.innerWidth < 770) {
        return null;
      }
      if (!e.target.value) {
        searchResultsContainer ? searchResultsContainer.setAttribute('class', 'dd') : null;
        return null;
      }

      searchText = e.target.value;
      var results = fuse.search(e.target.value);

      if (enableSearchHighlight) {
        renderSearchHighlightResults(searchText, results);
      } else {
        renderSearchResults(searchText, results);
      }

      var dropdownItems = searchResultsContainer.querySelectorAll('.dd-item');
      dropdownItems ? dropdownItems.forEach(function (item) {
        item.addEventListener('mousedown', function (e) {
          e.target.click();
        });
      }) : null;
    }) : null;

    var searchMenuElem = document.getElementById("search-menu");
    var activeItem = document.querySelector('#search-menu .dd-item.is-active');
    var activeIndex = null;
    var items = null;
    var searchContainerMaxHeight = 350;

    searchElem ? 
    searchElem.addEventListener('keydown', function(e) {
      if (window.innerWidth < 770) {
        return null;
      }

      var items = document.querySelectorAll('#search-menu .dd-item');
      
      if (e.key === 'ArrowDown') {
        if (activeIndex === null) {
          activeIndex = 0;
          items[activeIndex].classList.remove('is-active');
        } else {
          items[activeIndex].classList.remove('is-active');
          activeIndex = activeIndex === items.length - 1 ? 0 : activeIndex + 1;
        }
        items[activeIndex].classList.add('is-active');

        let overflowedPixel = items[activeIndex].offsetTop + items[activeIndex].clientHeight - searchContainerMaxHeight;
        if (overflowedPixel > 0) {
          document.querySelector(".search-content").scrollTop += items[activeIndex].getBoundingClientRect().height;
        } else if (activeIndex === 0) {
          document.querySelector(".search-content").scrollTop = 0;
        }
      } else if (e.key === 'ArrowUp') {
        if (activeIndex === null) {
          activeIndex = items.length - 1;
          items[activeIndex].classList.remove('is-active');
        } else {
          items[activeIndex].classList.remove('is-active');
          activeIndex = activeIndex === 0 ? items.length - 1 : activeIndex - 1;
        }
        items[activeIndex].classList.add('is-active');
        
        let overflowedPixel = items[activeIndex].offsetTop + items[activeIndex].clientHeight - searchContainerMaxHeight;
        if (overflowedPixel < 0) {
          document.querySelector(".search-content").scrollTop -= items[activeIndex].getBoundingClientRect().height;
        } else {
          document.querySelector(".search-content").scrollTop = overflowedPixel + items[activeIndex].getBoundingClientRect().height;
        }
      } else if (e.key === 'Enter') {
        var currentItemLink = items[activeIndex].getAttribute('href');
        if (currentItemLink) {
          location.href = currentItemLink;
        }
      } else if (e.key === 'Escape') {
        e.target.value = null;
        if (searchResults) {
          searchResults.classList.remove('is-active');
        }
      }
    }) : null;

    searchMobile ? 
    searchMobile.addEventListener('input', function(e) {
      if (!e.target.value) {
        let wrap = document.getElementById('search-mobile-results');
        while (wrap.firstChild) {
          wrap.removeChild(wrap.firstChild);
        }
        return null;
      }

      searchText = e.target.value;
      var results = fuse.search(e.target.value);
      
      if (enableSearchHighlight) {
        renderSearchHighlightResultsMobile(searchText, results);
      } else {
        renderSearchResultsMobile(searchText, results);
      }

      var dropdownItems = searchResultsContainer.querySelectorAll('.dd-item');
      dropdownItems ? dropdownItems.forEach(function (item) {
        item.addEventListener('mousedown', function (e) {
          e.target.click();
        });
      }) : null;
    }) : null;
  
  }
</script>
    


<link rel="stylesheet" href="/css/main.min.css">


    <meta name="description" content="" />
<meta name="keywords" content="">
<meta name="created" content="2021-05-30T11:10:22&#43;0000">
<meta name="modified" content="2021-05-30T11:10:24&#43;0000">
<meta name="author" content="邵晨峰">

<meta property="og:site_name" content="邵晨峰的博客">
<meta property="og:title" content="Camunda SpringBoot与进阶内容">
<meta property="og:url" content="http://shaochenfeng.com/camunda/camunda-springboot%E4%B8%8E%E8%BF%9B%E9%98%B6%E5%86%85%E5%AE%B9/">
<meta property="og:type" content="article">
<meta property="og:image" content="http://img.shaochenfeng.com/20210528085209.jpg">
<meta name="generator" content="Hugo 0.81.0" />
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="theme-color" content="#ffffff">
<link rel="canonical" href="http://shaochenfeng.com/camunda/camunda-springboot%E4%B8%8E%E8%BF%9B%E9%98%B6%E5%86%85%E5%AE%B9/">
<link rel="manifest" href="/manifest.json">

  <link rel="apple-touch-icon" sizes="57x57" href="/favicon/apple-icon-57x57.png">
  <link rel="apple-touch-icon" sizes="60x60" href="/favicon/apple-icon-60x60.png">
  <link rel="apple-touch-icon" sizes="72x72" href="/favicon/apple-icon-72x72.png">
  <link rel="apple-touch-icon" sizes="76x76" href="/favicon/apple-icon-76x76.png">
  <link rel="apple-touch-icon" sizes="114x114" href="/favicon/apple-icon-114x114.png">
  <link rel="apple-touch-icon" sizes="120x120" href="/favicon/apple-icon-120x120.png">
  <link rel="apple-touch-icon" sizes="144x144" href="/favicon/apple-icon-144x144.png">
  <link rel="apple-touch-icon" sizes="152x152" href="/favicon/apple-icon-152x152.png">
  <link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-icon-180x180.png">
  <link rel="icon" type="image/png" sizes="192x192" href="/favicon/android-icon-192x192.png">
  <link rel="icon" type="image/png" sizes="192x192" href="/favicon/android-icon-512x512.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="96x96" href="/favicon/favicon-96x96.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png">
  <meta name="msapplication-TileColor" content="#ffffff">
  <meta name="msapplication-TileImage" content="/ms-icon-144x144.png">

    <script type="application/ld+json">
  {
    "@context": "https://schema.org",
    "@type": "WebPage",
    "headline": "Camunda SpringBoot与进阶内容",
    "datePublished": "2021-05-30T11:10:22Z",
    "dateModified": "2021-05-30T11:10:24Z",
    "url" : "http://shaochenfeng.com/camunda/camunda-springboot%E4%B8%8E%E8%BF%9B%E9%98%B6%E5%86%85%E5%AE%B9/",
    "description": "介绍 在开始之前，首先确保你已经完成了快速入门部分 （http://shaochenfeng.com/blog/camunda-快速入门/） 本章",
    "keywords": ["activity","流程引擎"],
    "image" : "http://img.shaochenfeng.com/20210528085209.jpg",
    "author": {
      "@type": "Person",
      "name": "邵晨峰"
    },
    "mainEntityOfPage": {
      "@type": "WebPage",
      "@id": "http://shaochenfeng.com"
    },
    "publisher": {
      "@type": "Organization",
      "name": "邵晨峰的博客",
      "url": "http://shaochenfeng.com"
    }
  }
</script>

    
<script>

var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?bbd1a2ff6319307f954c5233f13dcc26";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
var _mtac = {};
(function() {
	var mta = document.createElement("script");
	mta.src = "//pingjs.qq.com/h5/stats.js?v2.0.4";
	mta.setAttribute("name", "MTAH5");
	mta.setAttribute("sid", "500711551");
	var s = document.getElementsByTagName("script")[0];
	s.parentNode.insertBefore(mta, s);
})();
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>

</head>


<body id="root" class="theme__light">
    <script>
        var rootElem = document.getElementById('root');
        var themeOptions = JSON.parse("[\"light\",\"dark\"]");
        var localTheme = localStorage.getItem('theme');

        if (localTheme) {
            if (themeOptions && themeOptions.length > 0) {
                themeOptions.includes(localTheme) ? 
                rootElem.className = `theme__${localTheme}` :
                rootElem.className = `theme__${themeOptions[0]}`;
            }
        }
    </script>
    
    <div id="container">
        <div id="myDrawer" class="drawer" style="">
  <div class="drawer__header">
    <a href="/" class="drawer__header--text">
      邵晨峰的博客
    </a>
    <div class="grow"></div>
    <div class="drawer__close">
      <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path fill="currentColor" d="M18.3 5.71c-.39-.39-1.02-.39-1.41 0L12 10.59 7.11 5.7c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.02 0 1.41L10.59 12 5.7 16.89c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0L12 13.41l4.89 4.89c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4z"/></svg>
    </div>
  </div>

  <div class="drawer__body">
    <div class="menu">
  <h6 class="menu__label">
    
    
      Camunda SpringBoot与进阶内容
    
  </h6>
  <ul>
    
    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/camunda/%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8%E4%BB%8B%E7%BB%8D/"
      class="menu__title ">快速入门介绍</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="active">
    <a href="http://shaochenfeng.com/camunda/camunda-springboot%E4%B8%8E%E8%BF%9B%E9%98%B6%E5%86%85%E5%AE%B9/"
      class="menu__title active">Camunda SpringBoot与进阶内容</a>
  </li>
  

    
  </ul>
</div>



<script>
  var menuTitle = document.querySelectorAll('.menu__title');
  var modal = document.getElementById("myModal");
  var drawer = document.getElementById('myDrawer');

  var closeDrawer = function () {
    setTimeout(function () {
      modal.style.opacity = 0;
      drawer.style.left = '-100%';
      modal.style.left = '-100%';
    }, 250);
  }

  menuTitle ? 
  menuTitle.forEach(function(elem) {
    elem.onclick = function() {
      closeDrawer();
      localStorage.setItem('isDrawerOpen', 'false');
    }
  }) : null;
</script>
  </div>
</div>
<div id="myModal" class="modal" style=""></div>

<script>
  var isDrawerOpen = localStorage.getItem('isDrawerOpen');
  var modal = document.getElementById("myModal");
  var drawer = document.getElementById('myDrawer');
  
  
  var languagedir = JSON.parse("\"ltr\"");

  var openDrawer = function () {
    modal.style.opacity = 1;
    
    if (languagedir === "rtl") {
      modal.style.right = 0;
      drawer.style.right = 0;
    } else {
      modal.style.left = 0;
      drawer.style.left = 0;
    }
  }

  if (isDrawerOpen && isDrawerOpen === 'true') {
    openDrawer();
  }
</script>
        
<nav class="nav">
  <div class="navbar__wrapper" data-bgimg="false">
    <div class="divider">
      <div class="navbar lmr">
        <div id="siteLogo" class="navbar__logo--wrapper">
  
    <a href="/" title="" rel="home" class="navbar__logo--link">
      <img src="/logo.png" alt="Home" class="navbar__logo">
    </a>
  
  
    <a href="/" title="" rel="home" class="navbar__logo--text-link">
      <h6 class="navbar__logo--text" data-bgimg="false">邵晨峰的博客</h6>
    </a>
  
</div>
        
        <div class="navbar__menu--wrapper">
          <div id="tabletLogo" class="hide">
  
  <a href="/" rel="home" class="navbar__logo--link">
    <img src="/logo.png" alt="Home" class="navbar__logo">
  </a>
  
</div>
          <div id="mobileLogo" class="hide">
  <a href="#" class="navbar__logo--link">
    <div class="navbar__icons--icon">
      <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path fill="currentColor" d="M4 18h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm0-5h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zM3 7c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1z"/></svg>
    </div>
  </a>
</div>
          <span id="navMenuMobile" class="hide">
  <button id="navCollapseBtn" class="navbar__dropdown--title" aria-label="Section Menu" data-dir="ltr">
    
      camunda
    
    <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"><path fill="currentColor" d="M8.12 9.29L12 13.17l3.88-3.88c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41l-4.59 4.59c-.39.39-1.02.39-1.41 0L6.7 10.7c-.39-.39-.39-1.02 0-1.41.39-.38 1.03-.39 1.42 0z"/></svg>
  </button>
  <div class="navbar__collapse" data-open="false">
  <ul>
    

  
  
  
  
  <li class="navbar__menu--mobile-item ">
    <a href="/blog" class="">博客</a>
  </li>

  
  
  
  
  <li class="navbar__menu--mobile-item ">
    <a href="/linux" class="">linux运维</a>
  </li>

  
  
  
  
  <li class="navbar__menu--mobile-item active">
    <a href="/camunda" class="active">camunda流程引擎</a>
  </li>

  </ul>
</div>
</span>
          <ul id="navMenu" class="navbar__menu">
            

  
  
  
  
  <li class="navbar__menu--item ">
    <a href="/blog" data-bgimg="false">博客</a>
  </li>

  
  
  
  
  <li class="navbar__menu--item ">
    <a href="/linux" data-bgimg="false">linux运维</a>
  </li>

  
  
  
  
  <li class="navbar__menu--item active">
    <a href="/camunda" data-bgimg="false">camunda流程引擎</a>
  </li>

          </ul>
        </div>
        <div class="grow"></div>
        <div id="siteSearch">
          

<div class="search" data-bgimg="false">
  <span class="icon">
    <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" fill="currentColor" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path d="M15.5 14h-.79l-.28-.27c1.2-1.4 1.82-3.31 1.48-5.34-.47-2.78-2.79-5-5.59-5.34-4.23-.52-7.79 3.04-7.27 7.27.34 2.8 2.56 5.12 5.34 5.59 2.03.34 3.94-.28 5.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>
  </span>
  <input id="search" aria-label="Site Search" class="input" type="text" autocomplete="no" onkeydown="baiduSearch(event);" placeholder="搜索">
  <div id="search-results" class="dropdown">
    <div id="search-menu" class="dropdown-menu">
    </div>
  </div>
</div>



        </div>
        <div id="mobileSearch" class="hide">
          
<div id="mobileSearchBtn" class="mobile-search__btn">
  <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" fill="currentColor" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path d="M15.5 14h-.79l-.28-.27c1.2-1.4 1.82-3.31 1.48-5.34-.47-2.78-2.79-5-5.59-5.34-4.23-.52-7.79 3.04-7.27 7.27.34 2.8 2.56 5.12 5.34 5.59 2.03.34 3.94-.28 5.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>
</div>

<div id="search-mobile-container" class="mobile-search hide">
  <div class="mobile-search__top">
    <input id="search-mobile" type="text" aria-label="Mobile Search" placeholder="Search..." class="mobile-search__top--input"/>
    <div id="search-mobile-close" class="mobile-search__top--icon">
      <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24"><path opacity=".87" fill="none" d="M0 0h24v24H0V0z"/><path fill="currentColor" d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm3.59-13L12 10.59 8.41 7 7 8.41 10.59 12 7 15.59 8.41 17 12 13.41 15.59 17 17 15.59 13.41 12 17 8.41z"/></svg>
    </div>
  </div>
  <div id="search-mobile-results" class="mobile-search__body">
    
  </div>
</div>

        </div>
        <div class="navbar__icons">
  
  
<button id="toggleToDark" class="navbar__icons--icon" aria-label="Toggle to dark mode">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zm0-2a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85l1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></svg>
</button>
<button id="toggleToLight" class="navbar__icons--icon" aria-label="Toggle to light mode">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.38 2.019a7.5 7.5 0 1 0 10.6 10.6C21.662 17.854 17.316 22 12.001 22 6.477 22 2 17.523 2 12c0-5.315 4.146-9.661 9.38-9.981z" fill="rgba(255,255,255,1)"/></svg>
</button>
<script>
  var theme = localStorage.getItem('theme');
  var toggleToLightBtn = document.getElementById('toggleToLight');
  var toggleToDarkBtn = document.getElementById('toggleToDark');

  if (theme && theme === 'dark') {
    toggleToLightBtn.className = 'navbar__icons--icon';
    toggleToDarkBtn.className = 'hide';
  } else {
    toggleToLightBtn.className = 'hide';
    toggleToDarkBtn.className = 'navbar__icons--icon';
  }
</script>

  
</div>


      </div>
    </div>
  </div>
</nav>

<script>
  var siteLogo = document.getElementById('siteLogo');
  var tabletLogo = document.getElementById('tabletLogo');
  var mobileLogo = document.getElementById('mobileLogo');
  var navMenu = document.getElementById('navMenu');
  var navMenuMobile = document.getElementById('navMenuMobile');
  var siteSearch = document.getElementById('siteSearch');
  var mobileSearch = document.getElementById('mobileSearch');
  
  enquire.register("screen and (max-width:1280px)", {
    match: function () {
      siteLogo.className = 'navbar__logo--wrapper';
      tabletLogo.className = 'hide';
      mobileLogo.className = 'hide';
      navMenu.className = 'navbar__menu';
      navMenuMobile.className = 'hide';
      siteSearch.className = '';
      mobileSearch.className = 'hide';
    },
    unmatch: function () {
      siteLogo.className = 'navbar__logo--wrapper';
      tabletLogo.className = 'hide';
      mobileLogo.className = 'hide';
      navMenu.className = 'navbar__menu';
      navMenuMobile.className = 'hide';
      siteSearch.className = '';
      mobileSearch.className = 'hide';
    },
  }).register("screen and (max-width:960px)", {
    match: function () {
      siteLogo.className = 'hide';
      tabletLogo.className = '';
      mobileLogo.className = 'hide';
      navMenu.className = 'navbar__menu';
      navMenuMobile.className = 'hide';
      siteSearch.className = 'hide';
      mobileSearch.className = 'navbar__icons--icon';
    },
    unmatch: function () {
      siteLogo.className = 'navbar__logo--wrapper';
      tabletLogo.className = 'hide';
      mobileLogo.className = 'hide';
      navMenu.className = 'navbar__menu';
      navMenuMobile.className = 'hide';
      siteSearch.className = '';
      mobileSearch.className = 'hide';
    },
  }).register("screen and (max-width:600px)", {
    match: function () {
      siteLogo.className = 'hide';
      tabletLogo.className = 'hide';
      mobileLogo.className = '';
      navMenu.className = 'hide';
      navMenuMobile.className = '';
      siteSearch.className = 'hide';
      mobileSearch.className = 'navbar__icons--icon';
    },
    unmatch: function () {
      siteLogo.className = 'hide';
      tabletLogo.className = '';
      mobileLogo.className = 'hide';
      navMenu.className = 'navbar__menu';
      navMenuMobile.className = 'hide';
      siteSearch.className = 'hide';
      mobileSearch.className = 'navbar__icons--icon';
    },
  });
</script>

        
  <div class="top">
  <div class="header__wrapper bgcolor__header">
    <div class="divider">
      <div class="lmr">
        
      </div>
    </div>
  </div>

  <div class="header__wrapper bgcolor__breadcrumb">
    <div class="divider">
      <div class="lmr flexbox">
        
          <nav class="breadcrumb" aria-label="breadcrumbs" data-is-blog="false">
  
  <ol>
    
  
    
    
  
    
    
  
  <li >
    
      <a href="http://shaochenfeng.com/" class="capitalize">主页</a>
    
  </li>
  
  
  <li >
    
      <a href="http://shaochenfeng.com/camunda/" class="capitalize">Camunda流程引擎</a>
    
  </li>
  
  
  <li  class="is-active" >
    
      <span>Camunda SpringBoot与进阶内容</span>
    
  </li>
  
  </ol>


  
</nav>
        
        <div class="grow"></div>
        
        
      </div>
    </div>
  </div>
</div>

        
  

<div class="mid">
  <div class="divider">
    
    <nav id="single-menu" class="l" data-dir="ltr">
      
        <div class="menu">
  
  <ul>
    
    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/camunda/%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8%E4%BB%8B%E7%BB%8D/"
      class="menu__title ">快速入门介绍</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="active">
    <a href="http://shaochenfeng.com/camunda/camunda-springboot%E4%B8%8E%E8%BF%9B%E9%98%B6%E5%86%85%E5%AE%B9/"
      class="menu__title active">Camunda SpringBoot与进阶内容</a>
  </li>
  

    
  </ul>
</div>


      
    </nav>

    <article id="list-main" class="m" data-dir="ltr">
      <div class="single" data-display="block">
  
  <article class="single__contents" data-dir="ltr">
    <h1 class="title" style="border-bottom: 1px solid currentColor">Camunda SpringBoot与进阶内容</h1>
    <h2 id="介绍">介绍</h2>
<p>在开始之前，首先确保你已经完成了<a href="/blog/camunda-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8/" target="_blank">快速入门部分</a> （<a href="/blog/camunda-%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/" target="_blank">http://shaochenfeng.com/blog/camunda-快速入门/</a>）</p>
<p>本章我们将继续完成 Camunda 官网上的其他入门部分，你将学到：</p>
<p>Spring Boot部分：</p>
<ol>
<li>创建 Camunda Spring Boot 项目</li>
<li>配置项目</li>
<li>使用“自动部署”功能部署流程</li>
<li>自定义HTML表格</li>
<li>在流程中调用 JAVA Class</li>
</ol>
<p>DMN部分：</p>
<ol>
<li>在JAVA端调用DMN决策</li>
<li>从DMN决策表与DRG决策图</li>
</ol>
<p>本教程对应官方教程中 Spring Boot 、DMN 、 JAVA Process Application 三章的内容，用一个例子串联起来，让我们开始吧！</p>
<h2 id="创建-camunda-spring-boot-项目">创建 Camunda Spring Boot 项目</h2>
<p>首先打开你喜欢的 IDE，新建一个空的Maven项目，本次的案例是“贷款审批”，所以项目名命名为<code>loan-approval-spring-boot</code>，groupId为<code>org.example</code></p>
<p>也可以使用命令行创建</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">mvn archetype:generate -DgroupId<span style="color:#555">=</span>org.example -DartifactId<span style="color:#555">=</span>loan-approval-spring-boot -Dversion<span style="color:#555">=</span>1.0-SNAPSHOT -DarchetypeArtifactId<span style="color:#555">=</span>maven-archetype-quickstart -DinactiveMode<span style="color:#555">=</span><span style="color:#366">false</span>
</code></pre></div><h3 id="配置maven依赖">配置Maven依赖</h3>
<p>接下来添加 Maven 依赖，Maven依赖需要添加到项目根目录下的 <code>pom.xml</code> 文件中。我们需要将 Spring Boot 依赖添加到 “dependency management” 中，然后将 Camunda Spring Boot Starter 添加为依赖，这将提供 Camunda 流程引擎和自带的 WebApp ；为简单起见，数据库使用嵌入式H2数据库；最后添加 <code>spring-boot-maven-plugin</code> ，它会将Spring Boot项目打包在一起。最终完成后效果如下：</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml"><span style="color:#099">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
<span style="color:#309;font-weight:bold">&lt;project</span> <span style="color:#309">xmlns=</span><span style="color:#c30">&#34;http://maven.apache.org/POM/4.0.0&#34;</span>
         <span style="color:#309">xmlns:xsi=</span><span style="color:#c30">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span>
         <span style="color:#309">xsi:schemaLocation=</span><span style="color:#c30">&#34;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&#34;</span><span style="color:#309;font-weight:bold">&gt;</span>
    <span style="color:#309;font-weight:bold">&lt;modelVersion&gt;</span>4.0.0<span style="color:#309;font-weight:bold">&lt;/modelVersion&gt;</span>

    <span style="color:#309;font-weight:bold">&lt;groupId&gt;</span>org.example<span style="color:#309;font-weight:bold">&lt;/groupId&gt;</span>
    <span style="color:#309;font-weight:bold">&lt;artifactId&gt;</span>loan-approval-spring-boot<span style="color:#309;font-weight:bold">&lt;/artifactId&gt;</span>
    <span style="color:#309;font-weight:bold">&lt;version&gt;</span>1.0-SNAPSHOT<span style="color:#309;font-weight:bold">&lt;/version&gt;</span>

    <span style="color:#309;font-weight:bold">&lt;properties&gt;</span>
        <span style="color:#309;font-weight:bold">&lt;camunda.spring-boot.version&gt;</span>7.15.0<span style="color:#309;font-weight:bold">&lt;/camunda.spring-boot.version&gt;</span>
        <span style="color:#309;font-weight:bold">&lt;spring-boot.version&gt;</span>2.4.4<span style="color:#309;font-weight:bold">&lt;/spring-boot.version&gt;</span>
        <span style="color:#309;font-weight:bold">&lt;maven.compiler.source&gt;</span>1.8<span style="color:#309;font-weight:bold">&lt;/maven.compiler.source&gt;</span>
        <span style="color:#309;font-weight:bold">&lt;maven.compiler.target&gt;</span>1.8<span style="color:#309;font-weight:bold">&lt;/maven.compiler.target&gt;</span>
    <span style="color:#309;font-weight:bold">&lt;/properties&gt;</span>

    <span style="color:#309;font-weight:bold">&lt;dependencyManagement&gt;</span>
        <span style="color:#309;font-weight:bold">&lt;dependencies&gt;</span>
            <span style="color:#309;font-weight:bold">&lt;dependency&gt;</span>
                <span style="color:#309;font-weight:bold">&lt;groupId&gt;</span>org.springframework.boot<span style="color:#309;font-weight:bold">&lt;/groupId&gt;</span>
                <span style="color:#309;font-weight:bold">&lt;artifactId&gt;</span>spring-boot-dependencies<span style="color:#309;font-weight:bold">&lt;/artifactId&gt;</span>
                <span style="color:#309;font-weight:bold">&lt;version&gt;</span>${spring-boot.version}<span style="color:#309;font-weight:bold">&lt;/version&gt;</span>
                <span style="color:#309;font-weight:bold">&lt;type&gt;</span>pom<span style="color:#309;font-weight:bold">&lt;/type&gt;</span>
                <span style="color:#309;font-weight:bold">&lt;scope&gt;</span>import<span style="color:#309;font-weight:bold">&lt;/scope&gt;</span>
            <span style="color:#309;font-weight:bold">&lt;/dependency&gt;</span>
        <span style="color:#309;font-weight:bold">&lt;/dependencies&gt;</span>
    <span style="color:#309;font-weight:bold">&lt;/dependencyManagement&gt;</span>

    <span style="color:#309;font-weight:bold">&lt;dependencies&gt;</span>
        <span style="color:#309;font-weight:bold">&lt;dependency&gt;</span>
            <span style="color:#309;font-weight:bold">&lt;groupId&gt;</span>org.camunda.bpm.springboot<span style="color:#309;font-weight:bold">&lt;/groupId&gt;</span>
            <span style="color:#309;font-weight:bold">&lt;artifactId&gt;</span>camunda-bpm-spring-boot-starter-webapp<span style="color:#309;font-weight:bold">&lt;/artifactId&gt;</span>
            <span style="color:#309;font-weight:bold">&lt;version&gt;</span>${camunda.spring-boot.version}<span style="color:#309;font-weight:bold">&lt;/version&gt;</span>
        <span style="color:#309;font-weight:bold">&lt;/dependency&gt;</span>
        <span style="color:#309;font-weight:bold">&lt;dependency&gt;</span>
            <span style="color:#309;font-weight:bold">&lt;groupId&gt;</span>com.h2database<span style="color:#309;font-weight:bold">&lt;/groupId&gt;</span>
            <span style="color:#309;font-weight:bold">&lt;artifactId&gt;</span>h2<span style="color:#309;font-weight:bold">&lt;/artifactId&gt;</span>
        <span style="color:#309;font-weight:bold">&lt;/dependency&gt;</span>
        <span style="color:#309;font-weight:bold">&lt;dependency&gt;</span>
            <span style="color:#309;font-weight:bold">&lt;groupId&gt;</span>com.sun.xml.bind<span style="color:#309;font-weight:bold">&lt;/groupId&gt;</span>
            <span style="color:#309;font-weight:bold">&lt;artifactId&gt;</span>jaxb-impl<span style="color:#309;font-weight:bold">&lt;/artifactId&gt;</span>
            <span style="color:#309;font-weight:bold">&lt;version&gt;</span>2.2.3<span style="color:#309;font-weight:bold">&lt;/version&gt;</span>
        <span style="color:#309;font-weight:bold">&lt;/dependency&gt;</span>
    <span style="color:#309;font-weight:bold">&lt;/dependencies&gt;</span>

    <span style="color:#309;font-weight:bold">&lt;build&gt;</span>
        <span style="color:#309;font-weight:bold">&lt;plugins&gt;</span>
            <span style="color:#309;font-weight:bold">&lt;plugin&gt;</span>
                <span style="color:#309;font-weight:bold">&lt;groupId&gt;</span>org.springframework.boot<span style="color:#309;font-weight:bold">&lt;/groupId&gt;</span>
                <span style="color:#309;font-weight:bold">&lt;artifactId&gt;</span>spring-boot-maven-plugin<span style="color:#309;font-weight:bold">&lt;/artifactId&gt;</span>
                <span style="color:#309;font-weight:bold">&lt;version&gt;</span>${spring-boot.version}<span style="color:#309;font-weight:bold">&lt;/version&gt;</span>
                <span style="color:#309;font-weight:bold">&lt;configuration&gt;</span>
                    <span style="color:#309;font-weight:bold">&lt;layout&gt;</span>ZIP<span style="color:#309;font-weight:bold">&lt;/layout&gt;</span>
                <span style="color:#309;font-weight:bold">&lt;/configuration&gt;</span>
                <span style="color:#309;font-weight:bold">&lt;executions&gt;</span>
                    <span style="color:#309;font-weight:bold">&lt;execution&gt;</span>
                        <span style="color:#309;font-weight:bold">&lt;goals&gt;</span>
                            <span style="color:#309;font-weight:bold">&lt;goal&gt;</span>repackage<span style="color:#309;font-weight:bold">&lt;/goal&gt;</span>
                        <span style="color:#309;font-weight:bold">&lt;/goals&gt;</span>
                    <span style="color:#309;font-weight:bold">&lt;/execution&gt;</span>
                <span style="color:#309;font-weight:bold">&lt;/executions&gt;</span>
            <span style="color:#309;font-weight:bold">&lt;/plugin&gt;</span>
        <span style="color:#309;font-weight:bold">&lt;/plugins&gt;</span>
    <span style="color:#309;font-weight:bold">&lt;/build&gt;</span>

<span style="color:#309;font-weight:bold">&lt;/project&gt;</span>
</code></pre></div><h3 id="为项目添加主类">为项目添加主类</h3>
<p>接下来，我们将为应用添加可以运行的主类，在 <code>src/main/java</code> 下新建一个类，类名为<code>WebappExampleProcessApplication</code>，包名为 <code>org.example.loanapproval</code></p>
<blockquote>
<p>如果使用命名行创建项目，会存在一个自带的<code>App.java</code>主类 ，这个不需要，删除即可</p>
</blockquote>
<p>Spring Boot的主类需要添加 <code>@SpringBootApplication</code> 注解，最后完成的效果如下：</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java"><span style="color:#069;font-weight:bold">package</span> <span style="color:#0cf;font-weight:bold">org.example.loanapproval</span><span style="color:#555">;</span>

<span style="color:#069;font-weight:bold">import</span> <span style="color:#0cf;font-weight:bold">org.springframework.boot.SpringApplication</span><span style="color:#555">;</span>
<span style="color:#069;font-weight:bold">import</span> <span style="color:#0cf;font-weight:bold">org.springframework.boot.autoconfigure.SpringBootApplication</span><span style="color:#555">;</span>

<span style="color:#99f">@SpringBootApplication</span>
<span style="color:#069;font-weight:bold">public</span> <span style="color:#069;font-weight:bold">class</span> <span style="color:#0a8;font-weight:bold">WebappExampleProcessApplication</span> <span style="color:#555">{</span>

    <span style="color:#069;font-weight:bold">public</span> <span style="color:#069;font-weight:bold">static</span> <span style="color:#078;font-weight:bold">void</span> <span style="color:#c0f">main</span><span style="color:#555">(</span>String<span style="color:#555">...</span> args<span style="color:#555">)</span> <span style="color:#555">{</span>
        SpringApplication<span style="color:#555">.</span><span style="color:#309">run</span><span style="color:#555">(</span>WebappExampleProcessApplication<span style="color:#555">.</span><span style="color:#309">class</span><span style="color:#555">,</span> args<span style="color:#555">);</span>
    <span style="color:#555">}</span>
<span style="color:#555">}</span>
</code></pre></div><blockquote>
<p>到此第一部分结束，如果想直接获取到现在为止的进度，可以下载<a href="https://gitee.com/zoollcar/camunda-get-started-spring-boot-and-dmn/repository/archive/Step-1.zip" target="_blank">zip包</a>，或者使用如下命令</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">git clone https://gitee.com/zoollcar/camunda-get-started-spring-boot-and-dmn.git
git checkout -f Step-1
</code></pre></div></blockquote>
<h3 id="配置项目">配置项目</h3>
<p>Camunda Spring Boot 自带了最佳实践配置，这些配置会在启动时自动启用，如果要覆盖部分配置，可以在 resources 中新增 <code>application.yaml</code> 或<code>application.properties</code>，默认配置的具体内容可以查看 <a href="https://docs.camunda.org/manual/latest/user-guide/spring-boot-integration/configuration/#camunda-engine-properties" target="_blank">https://docs.camunda.org/manual/latest/user-guide/spring-boot-integration/configuration/#camunda-engine-properties</a></p>
<h4 id="自定义管理员账户">自定义管理员账户</h4>
<p>让我们在 <code>src/main/resources</code> 下创建 <code>application.yaml</code>文件，输入如下内容：</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml"><span style="color:#309;font-weight:bold">camunda.bpm</span>:<span style="color:#bbb">
</span><span style="color:#bbb">  </span><span style="color:#309;font-weight:bold">admin-user</span>:<span style="color:#bbb">
</span><span style="color:#bbb">    </span><span style="color:#309;font-weight:bold">id</span>:<span style="color:#bbb"> </span>demo<span style="color:#bbb">
</span><span style="color:#bbb">    </span><span style="color:#309;font-weight:bold">password</span>:<span style="color:#bbb"> </span>demo<span style="color:#bbb">
</span><span style="color:#bbb">    </span><span style="color:#309;font-weight:bold">firstName</span>:<span style="color:#bbb"> </span>Demo<span style="color:#bbb">
</span><span style="color:#bbb">  </span><span style="color:#309;font-weight:bold">filter</span>:<span style="color:#bbb">
</span><span style="color:#bbb">    </span><span style="color:#309;font-weight:bold">create</span>:<span style="color:#bbb"> </span>All tasks<span style="color:#bbb">
</span></code></pre></div><p>以上配置将使用 demo 作为管理员用户名密码，在<code>Tasklist</code>中添加 <code>All tasks</code> 过滤器</p>
<h3 id="编译运行">编译运行</h3>
<p>IDE通常有工具可以直接编译运行，使用工具运行即可</p>
<p>也可以使用命令行运行：</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">mvn package
java -jar target/loan-approval-spring-boot-1.0-SNAPSHOT.jar
</code></pre></div><p>运行后打开浏览器访问：<a href="http://localhost:8080/" target="_blank">http://localhost:8080/</a> ，会自动打开登录界面，可以使用 demo/demo 登录，然后打开 Tasklist，可以看到 “All tasks”也被创建出来了。</p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210529112410.png" alt="image-20210529112402835"  />
</p></p>
<blockquote>
<p>到此第二部分结束，如果想直接获取到现在为止的进度，可以下载<a href="https://gitee.com/zoollcar/camunda-get-started-spring-boot-and-dmn/repository/archive/Step-2.zip" target="_blank">zip包</a>，或者使用如下命令</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">git clone https://gitee.com/zoollcar/camunda-get-started-spring-boot-and-dmn.git
git checkout -f Step-2
</code></pre></div></blockquote>
<h2 id="部署bpmn20流程">部署BPMN2.0流程</h2>
<p>在本章中，我们将要为刚才的Spring Boot项目部署流程，并使用监听器，在流程部署时发起流程</p>
<h3 id="编辑流程">编辑流程</h3>
<p>下载并打开 Camunda Modeler，编辑只包含一个人工节点的简单流程</p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210529114736.png" alt="image-20210529114736508"  />
</p></p>
<p>点击空白处，编辑流程id为 <code>loan-approval</code> ，Name 为 <code>Loan approval</code></p>
<blockquote>
<p>如果你对流程编辑不熟悉，可以阅读快速入门中的<a href="/blog/camunda-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8/#2%e7%bc%96%e8%be%91%e6%b5%81%e7%a8%8b" target="_blank">编辑流程部分</a></p>
</blockquote>
<p>流程编辑完成后，保存流程模型到项目的 <code>src/main/resources</code> 文件夹中，命名为 <code>loan-approval.bpmn</code>，然后重新编译运行项目。</p>
<p>浏览器中打开 <a href="http://localhost:8080/" target="_blank">http://localhost:8080/</a> ，点击 cockpit 可以看到流程已经部署到流程引擎中了</p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210529172210.png" alt="image-20210529172207409"  />
</p></p>
<blockquote>
<p>如果遇到报错：</p>
<p>src-resolve: 无法将名称 &lsquo;XXXX&rsquo; 解析为 &lsquo;element declaration&rsquo; 组件。</p>
<p>请检查项目路径是否有中文，这里要求路径不能包含中文。</p>
</blockquote>
<h3 id="为项目启用流程支持">为项目启用流程支持</h3>
<p>现在我们在 Camunda Spring Boot 项目中添加 <code>@EnableProcessApplication</code> 注解，这会提供更多可配置项，以及启用更多流程相关注解。</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java"><span style="color:#069;font-weight:bold">package</span> <span style="color:#0cf;font-weight:bold">org.example.loanapproval</span><span style="color:#555">;</span>

<span style="color:#069;font-weight:bold">import</span> <span style="color:#0cf;font-weight:bold">org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication</span><span style="color:#555">;</span>
<span style="color:#069;font-weight:bold">import</span> <span style="color:#0cf;font-weight:bold">org.springframework.boot.SpringApplication</span><span style="color:#555">;</span>
<span style="color:#069;font-weight:bold">import</span> <span style="color:#0cf;font-weight:bold">org.springframework.boot.autoconfigure.SpringBootApplication</span><span style="color:#555">;</span>

<span style="color:#99f">@SpringBootApplication</span>
<span style="color:#99f">@EnableProcessApplication</span> <span style="color:#09f;font-style:italic">// 新增
</span><span style="color:#09f;font-style:italic"></span><span style="color:#069;font-weight:bold">public</span> <span style="color:#069;font-weight:bold">class</span> <span style="color:#0a8;font-weight:bold">WebappExampleProcessApplication</span> <span style="color:#555">{</span>

    <span style="color:#069;font-weight:bold">public</span> <span style="color:#069;font-weight:bold">static</span> <span style="color:#078;font-weight:bold">void</span> <span style="color:#c0f">main</span><span style="color:#555">(</span>String<span style="color:#555">...</span> args<span style="color:#555">)</span> <span style="color:#555">{</span>
        SpringApplication<span style="color:#555">.</span><span style="color:#309">run</span><span style="color:#555">(</span>WebappExampleProcessApplication<span style="color:#555">.</span><span style="color:#309">class</span><span style="color:#555">,</span> args<span style="color:#555">);</span>
    <span style="color:#555">}</span>
<span style="color:#555">}</span>
</code></pre></div><p>添加完注解后，需要新建 Camunda 配置文件——<code>src/main/resources/META-INF/processes.xml</code>，<code>META-INF</code>文件夹可能不存在，需要新建后，在其中增加<code>processes.xml</code>，这个文件暂时留空，但对于 Camunda 来说却是必要的。</p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210529180648.png" alt="image-20210529180648434"  />
</p></p>
<h3 id="流程部署时发起流程测试">流程部署时发起流程测试</h3>
<p>下一步是一项测试，我们希望在流程部署完成后发起一次流程，需要用到事件监听注解<code>@EventListener</code>，监听的类型为 <code>PostDeployEvent</code> （流程部署），修改后的 <code>WebappExampleProcessApplication</code> 如下：</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java"><span style="color:#99f">@SpringBootApplication</span>
<span style="color:#99f">@EnableProcessApplication</span>
<span style="color:#069;font-weight:bold">public</span> <span style="color:#069;font-weight:bold">class</span> <span style="color:#0a8;font-weight:bold">WebappExampleProcessApplication</span> <span style="color:#555">{</span>

    <span style="color:#069;font-weight:bold">public</span> <span style="color:#069;font-weight:bold">static</span> <span style="color:#078;font-weight:bold">void</span> <span style="color:#c0f">main</span><span style="color:#555">(</span>String<span style="color:#555">...</span> args<span style="color:#555">)</span> <span style="color:#555">{</span>
        SpringApplication<span style="color:#555">.</span><span style="color:#309">run</span><span style="color:#555">(</span>WebappExampleProcessApplication<span style="color:#555">.</span><span style="color:#309">class</span><span style="color:#555">,</span> args<span style="color:#555">);</span>
    <span style="color:#555">}</span>

    <span style="color:#09f;font-style:italic">// &gt;&gt;新增
</span><span style="color:#09f;font-style:italic"></span>    <span style="color:#99f">@Autowired</span>
    <span style="color:#069;font-weight:bold">private</span> RuntimeService runtimeService<span style="color:#555">;</span>

    <span style="color:#99f">@EventListener</span>
    <span style="color:#069;font-weight:bold">private</span> <span style="color:#078;font-weight:bold">void</span> <span style="color:#c0f">processPostDeploy</span><span style="color:#555">(</span>PostDeployEvent event<span style="color:#555">)</span> <span style="color:#555">{</span>
        runtimeService<span style="color:#555">.</span><span style="color:#309">startProcessInstanceByKey</span><span style="color:#555">(</span><span style="color:#c30">&#34;loanApproval&#34;</span><span style="color:#555">);</span>
    <span style="color:#555">}</span>
    <span style="color:#09f;font-style:italic">// &lt;&lt;
</span><span style="color:#09f;font-style:italic"></span><span style="color:#555">}</span>
</code></pre></div><p>修改后，我们再次重启项目，浏览器中打开 <a href="http://localhost:8080/" target="_blank">http://localhost:8080/</a>  ，点击 Tasklist 进入，可以看到新创建的流程实例人工任务</p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210529180604.png" alt="image-20210529180604050"  />
</p></p>
<blockquote>
<p>到此第三部分结束，如果想直接获取到现在为止的进度，可以下载<a href="https://gitee.com/zoollcar/camunda-get-started-spring-boot-and-dmn/repository/archive/Step-3.zip" target="_blank">zip包</a>，或者使用如下命令</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">git clone https://gitee.com/zoollcar/camunda-get-started-spring-boot-and-dmn.git
git checkout -f Step-3
</code></pre></div></blockquote>
<h2 id="添加自定义表单">添加自定义表单</h2>
<p><a href="/blog/camunda-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8" target="_blank">快速入门</a>中，我们通过form选项卡添加过表单，通过变量名和变量类型简单的生成了自带表单，本章我们将使用自定义html嵌入的方式，让表单具有更大的灵活性。</p>
<h3 id="添加申请表单">添加申请表单</h3>
<p>我们需要将自定义表单放入Spring Boot静态资源文件夹，在 <code>resources</code> 中新建目录<code>static/forms</code>，然后新建申请表单，内容如下，命名为 <code>loan-approval.html</code>，保存到 <code>resources/static/forms</code> 目录</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html">&lt;<span style="color:#309;font-weight:bold">form</span> <span style="color:#309">name</span><span style="color:#555">=</span><span style="color:#c30">&#34;loanApproval&#34;</span>&gt;
    &lt;<span style="color:#309;font-weight:bold">div</span> <span style="color:#309">class</span><span style="color:#555">=</span><span style="color:#c30">&#34;form-group&#34;</span>&gt;
        &lt;<span style="color:#309;font-weight:bold">label</span> <span style="color:#309">for</span><span style="color:#555">=</span><span style="color:#c30">&#34;lenderId&#34;</span>&gt;贷款人&lt;/<span style="color:#309;font-weight:bold">label</span>&gt;
        &lt;<span style="color:#309;font-weight:bold">input</span> <span style="color:#309">class</span><span style="color:#555">=</span><span style="color:#c30">&#34;form-control&#34;</span>
               <span style="color:#309">cam-variable-type</span><span style="color:#555">=</span><span style="color:#c30">&#34;String&#34;</span>
               <span style="color:#309">cam-variable-name</span><span style="color:#555">=</span><span style="color:#c30">&#34;lenderId&#34;</span>
               <span style="color:#309">name</span><span style="color:#555">=</span><span style="color:#c30">&#34;lenderId&#34;</span> /&gt;
    &lt;/<span style="color:#309;font-weight:bold">div</span>&gt;
    &lt;<span style="color:#309;font-weight:bold">div</span> <span style="color:#309">class</span><span style="color:#555">=</span><span style="color:#c30">&#34;form-group&#34;</span>&gt;
        &lt;<span style="color:#309;font-weight:bold">label</span> <span style="color:#309">for</span><span style="color:#555">=</span><span style="color:#c30">&#34;amount&#34;</span>&gt;金额&lt;/<span style="color:#309;font-weight:bold">label</span>&gt;
        &lt;<span style="color:#309;font-weight:bold">input</span> <span style="color:#309">class</span><span style="color:#555">=</span><span style="color:#c30">&#34;form-control&#34;</span>
               <span style="color:#309">cam-variable-type</span><span style="color:#555">=</span><span style="color:#c30">&#34;Double&#34;</span>
               <span style="color:#309">cam-variable-name</span><span style="color:#555">=</span><span style="color:#c30">&#34;amount&#34;</span>
               <span style="color:#309">name</span><span style="color:#555">=</span><span style="color:#c30">&#34;amount&#34;</span> /&gt;
    &lt;/<span style="color:#309;font-weight:bold">div</span>&gt;
&lt;/<span style="color:#309;font-weight:bold">form</span>&gt;
</code></pre></div><p>打开 Camunda Modeler ，点击 “发起贷款申请” 节点，在右侧属性菜单选择Forms，写入 <code>embedded:app:forms/loan-approval.html</code> 这意味着表单将以嵌入式的方式添加进 Tasklist 中</p>
<h3 id="添加检查申请单节点表单">添加“检查申请单”节点表单</h3>
<p>同样的，我们新建 <code>loan-auth.html</code> 到 <code>resources/static/forms</code> 目录，内容如下：</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html">&lt;<span style="color:#309;font-weight:bold">form</span> <span style="color:#309">name</span><span style="color:#555">=</span><span style="color:#c30">&#34;loanAuth&#34;</span>&gt;
    &lt;<span style="color:#309;font-weight:bold">div</span> <span style="color:#309">class</span><span style="color:#555">=</span><span style="color:#c30">&#34;form-group&#34;</span>&gt;
        &lt;<span style="color:#309;font-weight:bold">label</span> <span style="color:#309">for</span><span style="color:#555">=</span><span style="color:#c30">&#34;lenderId&#34;</span>&gt;贷款人&lt;/<span style="color:#309;font-weight:bold">label</span>&gt;
        &lt;<span style="color:#309;font-weight:bold">input</span> <span style="color:#309">class</span><span style="color:#555">=</span><span style="color:#c30">&#34;form-control&#34;</span>
               <span style="color:#309">cam-variable-type</span><span style="color:#555">=</span><span style="color:#c30">&#34;String&#34;</span>
               <span style="color:#309">cam-variable-name</span><span style="color:#555">=</span><span style="color:#c30">&#34;lenderId&#34;</span>
               <span style="color:#309">name</span><span style="color:#555">=</span><span style="color:#c30">&#34;lenderId&#34;</span>
               <span style="color:#309">readonly</span><span style="color:#555">=</span><span style="color:#c30">&#34;true&#34;</span> /&gt;
    &lt;/<span style="color:#309;font-weight:bold">div</span>&gt;
    &lt;<span style="color:#309;font-weight:bold">div</span> <span style="color:#309">class</span><span style="color:#555">=</span><span style="color:#c30">&#34;form-group&#34;</span>&gt;
        &lt;<span style="color:#309;font-weight:bold">label</span> <span style="color:#309">for</span><span style="color:#555">=</span><span style="color:#c30">&#34;amount&#34;</span>&gt;金额&lt;/<span style="color:#309;font-weight:bold">label</span>&gt;
        &lt;<span style="color:#309;font-weight:bold">input</span> <span style="color:#309">class</span><span style="color:#555">=</span><span style="color:#c30">&#34;form-control&#34;</span>
               <span style="color:#309">cam-variable-type</span><span style="color:#555">=</span><span style="color:#c30">&#34;Double&#34;</span>
               <span style="color:#309">cam-variable-name</span><span style="color:#555">=</span><span style="color:#c30">&#34;amount&#34;</span>
               <span style="color:#309">name</span><span style="color:#555">=</span><span style="color:#c30">&#34;amount&#34;</span> /&gt;
    &lt;/<span style="color:#309;font-weight:bold">div</span>&gt;
&lt;/<span style="color:#309;font-weight:bold">form</span>&gt;
</code></pre></div><p>打开 Camunda Modeler ，点击 “检查申请单” 节点，在右侧属性菜单选择Forms，写入 <code>embedded:app:forms/loan-auth.html</code></p>
<h3 id="测试一下">测试一下</h3>
<p>重新编译并运行项目，浏览器中打开 <a href="http://localhost:8080/" target="_blank">http://localhost:8080/</a>  ，点击 Tasklist 进入，点击右上角 <code>Start Process</code>，可以看到表单已经嵌入到 Tasklist 中了，发起流程后，任务列表中可以看到审核界面的表单</p>
<p><p class="md__image">
  <img src="/C:%5CUsers%5Czoollcar%5CAppData%5CRoaming%5CTypora%5Ctypora-user-images%5Cimage-20210529191213757.png" alt="image-20210529191211238"  />
</p></p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210529191244.png" alt="image-20210529191244743"  />
</p></p>
<blockquote>
<p>到此第四部分结束，如果想直接获取到现在为止的进度，可以下载<a href="https://gitee.com/zoollcar/camunda-get-started-spring-boot-and-dmn/repository/archive/Step-4.zip" target="_blank">zip包</a>，或者使用如下命令</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">git clone https://gitee.com/zoollcar/camunda-get-started-spring-boot-and-dmn.git
git checkout -f Step-4
</code></pre></div></blockquote>
<h2 id="在流程中调用-java-class">在流程中调用 JAVA Class</h2>
<p>在本章中我们将学到如何使用流程的 <code>Service task（服务任务）</code> 中调用JAVA类。</p>
<h3 id="将-service-task-添加到流程中">将 Service Task 添加到流程中</h3>
<p>打开 Camunda Modeler ，在左侧工具架中选择 Task（矩形），拖动到“检查申请单”后面，双击命名为“发放贷款”</p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210530095501.png" alt="image-20210530095026791"  />
</p></p>
<p>点击新创建的节点，点击右侧弹出的扳手按钮，将类型修改为 Service Task。</p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210530095509.png" alt="image-20210530095147567"  />
</p></p>
<h3 id="实现-javadelegate-类">实现 JavaDelegate 类</h3>
<p>现在我们需要添加 Service Task 可以调用的实现类，将类添加到 <code>org.example.loanapproval</code> 包下，命名为 <code>OfferLoan</code>，这里我们希望打印贷款人信息到日志，具体代码如下：</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java"><span style="color:#069;font-weight:bold">package</span> <span style="color:#0cf;font-weight:bold">org.example.loanapproval</span><span style="color:#555">;</span>

<span style="color:#069;font-weight:bold">import</span> <span style="color:#0cf;font-weight:bold">java.util.logging.Logger</span><span style="color:#555">;</span>
<span style="color:#069;font-weight:bold">import</span> <span style="color:#0cf;font-weight:bold">org.camunda.bpm.engine.delegate.DelegateExecution</span><span style="color:#555">;</span>
<span style="color:#069;font-weight:bold">import</span> <span style="color:#0cf;font-weight:bold">org.camunda.bpm.engine.delegate.JavaDelegate</span><span style="color:#555">;</span>

<span style="color:#069;font-weight:bold">public</span> <span style="color:#069;font-weight:bold">class</span> <span style="color:#0a8;font-weight:bold">OfferLoan</span> <span style="color:#069;font-weight:bold">implements</span> JavaDelegate <span style="color:#555">{</span>

    <span style="color:#069;font-weight:bold">private</span> <span style="color:#069;font-weight:bold">final</span> <span style="color:#069;font-weight:bold">static</span> Logger LOGGER <span style="color:#555">=</span> Logger<span style="color:#555">.</span><span style="color:#309">getLogger</span><span style="color:#555">(</span><span style="color:#c30">&#34;LOAN-REQUESTS&#34;</span><span style="color:#555">);</span>

    <span style="color:#99f">@Override</span>
    <span style="color:#069;font-weight:bold">public</span> <span style="color:#078;font-weight:bold">void</span> <span style="color:#c0f">execute</span><span style="color:#555">(</span>DelegateExecution execution<span style="color:#555">)</span> <span style="color:#555">{</span>
        LOGGER<span style="color:#555">.</span><span style="color:#309">info</span><span style="color:#555">(</span><span style="color:#c30">&#34;offer &#34;</span> <span style="color:#555">+</span> execution<span style="color:#555">.</span><span style="color:#309">getVariable</span><span style="color:#555">(</span><span style="color:#c30">&#34;lenderId&#34;</span><span style="color:#555">)</span> <span style="color:#555">+</span> <span style="color:#c30">&#34; loans&#34;</span><span style="color:#555">);</span>
    <span style="color:#555">}</span>
<span style="color:#555">}</span>
</code></pre></div><h3 id="配置-service-task">配置 Service Task</h3>
<p>回到 Camunda Modeler ，选择“发放贷款”节点，在右侧的属性面板中，选择 <code>Implementation</code>为 <code>Java Class</code> ，Java Class 为我们刚才创建的类 <code>org.example.loanapproval.OfferLoan</code></p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210530100558.png" alt="image-20210530100557989"  />
</p></p>
<p>保存流程</p>
<h3 id="测试一下-1">测试一下</h3>
<p>重新编译并运行项目，浏览器中打开 <a href="http://localhost:8080/" target="_blank">http://localhost:8080/</a>  ，点击 Tasklist 进入，点击右上角 <code>Start Process</code>，启动一个新流程</p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210530100856.png" alt="image-20210530100856310"  />
</p></p>
<p>刷新页面，完成人工任务</p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210530101045.png" alt="image-20210530101045803"  />
</p></p>
<p>检查 Spring Boot 程序控制台输出，可以看到贷款人信息已经被打印出来了</p>
<pre><code>INFO 3156 --- [nio-8080-exec-6] LOAN-REQUESTS    : offer 张三 loans
</code></pre><blockquote>
<p>到此第五部分结束，如果想直接获取到现在为止的进度，可以下载<a href="https://gitee.com/zoollcar/camunda-get-started-spring-boot-and-dmn/repository/archive/Step-5.zip" target="_blank">zip包</a>，或者使用如下命令</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">git clone https://gitee.com/zoollcar/camunda-get-started-spring-boot-and-dmn.git
git checkout -f Step-5
</code></pre></div></blockquote>
<h2 id="在-java-中调用-dmn-决策">在 JAVA 中调用 DMN 决策</h2>
<p>在本章中，我们将会学到创建一个DMN决策并部署到流程引擎中，以及在JAVA里调用测试我们的DMN。</p>
<p>我们使用BMI健康状况作为案例，BMI是身高体重的比值，通常用于判断人的胖瘦程度。</p>
<h3 id="创建新的-dmn">创建新的 DMN</h3>
<p>启动  Camunda Modeler，点击工具栏最左侧的新建按钮，新建一个 DMN</p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210530102641.png" alt="image-20210530102641913"  />
</p></p>
<h3 id="配置dmn决策">配置DMN决策</h3>
<p>点击画布上默认的DMN决策表，修改在右侧的属性面板中的<code>id</code>为 <code>bmi-classification</code>，<code>Name</code>为 <code>BMI Classification</code></p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210530123738.png" alt="image-20210530123738150"  />
</p></p>
<p>下一步，点击左上角的表格按钮，进入决策编辑界面</p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210530124215.png" alt="image-20210530124215208"  />
</p></p>
<p>双击 input 区域，<em>input</em>修改为<code>BMI</code>，<em>Expression</em>修改为<code>bmi</code>，<em>Type</em>选择<code>douoble</code></p>
<p>同样的，双击output区域，<em>output</em>修改为 <code>result</code>，<em>Output Name</em>修改为<code>result</code>，<em>Type</em>选择<code>string</code></p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210530124706.png" alt="image-20210530124706490"  />
</p></p>
<p>点击表格左侧的蓝色加号，添加BMI分类规则，最终效果如下：</p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210530124813.png" alt="image-20210530124813693"  />
</p></p>
<p>确保顶部<a href="https://docs.camunda.org/manual/latest/reference/dmn11/decision-table/hit-policy/" target="_blank"><strong>Hit Policy</strong>（命中策略）</a>为“UNIQUE（唯一）”，在“唯一”模式下，只有所有规则都是互斥的，一个输入只能匹配一种规则。</p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210530161531.png" alt="image-20210530161531665"  />
</p></p>
<blockquote>
<p>默认的规则就是“唯一”，这条规则可以自动匹配，不需要更改。</p>
</blockquote>
<h3 id="保存决策表">保存决策表</h3>
<p>编辑完成后，点击工具栏“save”按钮，将流程保存到项目的 <code>src/main/resources</code>目录下。</p>
<blockquote>
<p>到此第六部分结束，如果想直接获取到现在为止的进度，可以下载<a href="https://gitee.com/zoollcar/camunda-get-started-spring-boot-and-dmn/repository/archive/Step-6.zip" target="_blank">zip包</a>，或者使用如下命令</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">git clone https://gitee.com/zoollcar/camunda-get-started-spring-boot-and-dmn.git
git checkout -f Step-6
</code></pre></div></blockquote>
<h3 id="在java中调用dmn决策表">在JAVA中调用DMN决策表</h3>
<p>我们将在决策表部署完成后调用测试，因此如下修改主类：</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java"><span style="color:#069;font-weight:bold">package</span> <span style="color:#0cf;font-weight:bold">org.example.loanapproval</span><span style="color:#555">;</span>

<span style="color:#09f;font-style:italic">//import ...
</span><span style="color:#09f;font-style:italic"></span>
<span style="color:#069;font-weight:bold">import</span> <span style="color:#0cf;font-weight:bold">java.util.logging.Level</span><span style="color:#555">;</span>
<span style="color:#069;font-weight:bold">import</span> <span style="color:#0cf;font-weight:bold">java.util.logging.Logger</span><span style="color:#555">;</span>

<span style="color:#99f">@SpringBootApplication</span>
<span style="color:#99f">@EnableProcessApplication</span>
<span style="color:#069;font-weight:bold">public</span> <span style="color:#069;font-weight:bold">class</span> <span style="color:#0a8;font-weight:bold">WebappExampleProcessApplication</span> <span style="color:#555">{</span>
	
    <span style="color:#09f;font-style:italic">// 增加logger用于打印决策后的结果
</span><span style="color:#09f;font-style:italic"></span>    <span style="color:#069;font-weight:bold">protected</span> <span style="color:#069;font-weight:bold">final</span> <span style="color:#069;font-weight:bold">static</span> Logger LOGGER <span style="color:#555">=</span> Logger<span style="color:#555">.</span><span style="color:#309">getLogger</span><span style="color:#555">(</span>WebappExampleProcessApplication<span style="color:#555">.</span><span style="color:#309">class</span><span style="color:#555">.</span><span style="color:#309">getName</span><span style="color:#555">());</span>

    <span style="color:#069;font-weight:bold">public</span> <span style="color:#069;font-weight:bold">static</span> <span style="color:#078;font-weight:bold">void</span> <span style="color:#c0f">main</span><span style="color:#555">(</span>String<span style="color:#555">...</span> args<span style="color:#555">)</span> <span style="color:#555">{</span>
        SpringApplication<span style="color:#555">.</span><span style="color:#309">run</span><span style="color:#555">(</span>WebappExampleProcessApplication<span style="color:#555">.</span><span style="color:#309">class</span><span style="color:#555">,</span> args<span style="color:#555">);</span>
    <span style="color:#555">}</span>

    <span style="color:#99f">@Autowired</span>
    <span style="color:#069;font-weight:bold">private</span> RuntimeService runtimeService<span style="color:#555">;</span>

    <span style="color:#99f">@EventListener</span>
    <span style="color:#069;font-weight:bold">private</span> <span style="color:#078;font-weight:bold">void</span> <span style="color:#c0f">processPostDeploy</span><span style="color:#555">(</span>PostDeployEvent event<span style="color:#555">)</span> <span style="color:#555">{</span>
        runtimeService<span style="color:#555">.</span><span style="color:#309">startProcessInstanceByKey</span><span style="color:#555">(</span><span style="color:#c30">&#34;loan-approval&#34;</span><span style="color:#555">);</span>
		
        <span style="color:#09f;font-style:italic">// &gt;&gt;&gt;&gt; 新增
</span><span style="color:#09f;font-style:italic"></span>        DecisionService decisionService <span style="color:#555">=</span> event<span style="color:#555">.</span><span style="color:#309">getProcessEngine</span><span style="color:#555">().</span><span style="color:#309">getDecisionService</span><span style="color:#555">();</span>
		<span style="color:#09f;font-style:italic">// 输入参数
</span><span style="color:#09f;font-style:italic"></span>        VariableMap variables <span style="color:#555">=</span> Variables<span style="color:#555">.</span><span style="color:#309">createVariables</span><span style="color:#555">()</span>
                <span style="color:#555">.</span><span style="color:#309">putValue</span><span style="color:#555">(</span><span style="color:#c30">&#34;bmi&#34;</span><span style="color:#555">,</span> 20<span style="color:#555">.</span><span style="color:#309">0</span><span style="color:#555">);</span>
		<span style="color:#09f;font-style:italic">// 调用决策
</span><span style="color:#09f;font-style:italic"></span>        DmnDecisionTableResult dmnDecisionTableResult <span style="color:#555">=</span> decisionService
                <span style="color:#555">.</span><span style="color:#309">evaluateDecisionTableByKey</span><span style="color:#555">(</span><span style="color:#c30">&#34;bpm-classification&#34;</span><span style="color:#555">,</span> variables<span style="color:#555">);</span>
        String result <span style="color:#555">=</span> dmnDecisionTableResult<span style="color:#555">.</span><span style="color:#309">getSingleEntry</span><span style="color:#555">();</span>
		<span style="color:#09f;font-style:italic">// 打印结果
</span><span style="color:#09f;font-style:italic"></span>        LOGGER<span style="color:#555">.</span><span style="color:#309">log</span><span style="color:#555">(</span>Level<span style="color:#555">.</span><span style="color:#309">INFO</span><span style="color:#555">,</span> <span style="color:#c30">&#34;\n\nBMI Classification result is : {0}\n\n&#34;</span><span style="color:#555">,</span> result<span style="color:#555">);</span>
        <span style="color:#09f;font-style:italic">// &lt;&lt;&lt;&lt;
</span><span style="color:#09f;font-style:italic"></span>    <span style="color:#555">}</span>
<span style="color:#555">}</span>

</code></pre></div><blockquote>
<p>到此第七部分结束，如果想直接获取到现在为止的进度，可以下载<a href="https://gitee.com/zoollcar/camunda-get-started-spring-boot-and-dmn/repository/archive/Step-7zip" target="_blank">zip包</a>，或者使用如下命令</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">git clone https://gitee.com/zoollcar/camunda-get-started-spring-boot-and-dmn.git
git checkout -f Step-7
</code></pre></div></blockquote>
<h3 id="测试一下-2">测试一下</h3>
<p>编译项目并重新运行，查看 Spring Boot 输出，如果看到：</p>
<pre><code>BMI Classification result is : 正常
</code></pre><p>表示执行成功了</p>
<p>用浏览器打开 <a href="http://localhost:8080/camunda/app/cockpit/" target="_blank">http://localhost:8080/camunda/app/cockpit/</a> 使用 demo/demo 登录，打开 Decision Definitions，可以找到刚才的流程实例，可以看到判定结果</p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210530180030.png" alt="image-20210530180030428"  />
</p></p>
<h2 id="从dmn决策表与drg决策图">从DMN决策表与DRG决策图</h2>
<p>这一章，我们将创建新的DMN决策表，并将两个DMN决策表组成一张DRG决策图，最后通过JAVA调用，获得两个决策表协同得到的结果。</p>
<blockquote>
<p>DMN与DRG：</p>
<p>DMN本质上就是一组输入输出的对应关系，体现的是一个简单决策，不应该过于复杂，对于需要多次决策才能得到答案的复杂决策，可以将多个简单的DMN连接起来，组成DRG决策图。</p>
</blockquote>
<blockquote>
<p>DRG与DRD</p>
<p>DRD是使用可视化的方式显示和编辑DRG的方式，因为Camunda Modeler是可视化的，所以在Camunda Modeler中显示未DRD</p>
</blockquote>
<h3 id="配置drd决策图">配置DRD决策图</h3>
<p>点击左上角的 Edit DRD 切换到 DRD编辑界面</p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210530182724.png" alt="image-20210530182650448"  />
</p></p>
<p>就像编辑流程一样，点击空白处，修改DRD的id为 <code>bmi-health</code> ，Name为 <code>BMI Health</code></p>
<h3 id="创建新的dmn决策到drd">创建新的DMN决策到DRD</h3>
<p>现在可以创建一个新的决策了，我们希望在评估完BMI类型后给出建议，则拖动左侧正方形到画布，双击修改名称为 <code>BMI Suggestion</code>，切换类型为 Decision Table，最后修改id为 <code>bmi-suggestion</code></p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210530183511.png" alt="image-20210530183511220"  />
</p></p>
<p>点击 “BMI Classification” 节点，选择弹出的连线，连接到新的“BMI Suggestion”节点，这表示，新节点<a href="https://docs.camunda.org/manual/latest/reference/dmn11/drg/#required-decisions" target="_blank">依赖于</a>“BMI Classification”</p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210530184112.png" alt="image-20210530184112199"  />
</p></p>
<h3 id="编辑bmi-suggestion决策">编辑“BMI Suggestion”决策</h3>
<p>点击 “BMI Suggestion” 节点左上角的表格按钮，进入编辑界面，输入内容如下：</p>
<p>“Input”为<code>result</code> ，“Expression”为 <code>result</code></p>
<p>“Output”为<code>suggestion</code> ，“Expression”为 <code>suggestion</code></p>
<p><p class="md__image">
  <img src="http://img.shaochenfeng.com/20210530185323.png" alt="image-20210530185323584"  />
</p></p>
<h3 id="在java中执行">在JAVA中执行</h3>
<p>执行DRG决策图的方法就是执行它的最后一个节点，因为DRG的节点之间具有依赖关系，在执行最后一个节点前会执行它所以来的决策</p>
<p>所以新增的代码与执行DMN一样，修改后的主类如下：</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java"><span style="color:#09f;font-style:italic">// ...
</span><span style="color:#09f;font-style:italic"></span><span style="color:#99f">@SpringBootApplication</span>
<span style="color:#99f">@EnableProcessApplication</span>
<span style="color:#069;font-weight:bold">public</span> <span style="color:#069;font-weight:bold">class</span> <span style="color:#0a8;font-weight:bold">WebappExampleProcessApplication</span> <span style="color:#555">{</span>

    <span style="color:#069;font-weight:bold">protected</span> <span style="color:#069;font-weight:bold">final</span> <span style="color:#069;font-weight:bold">static</span> Logger LOGGER <span style="color:#555">=</span> Logger<span style="color:#555">.</span><span style="color:#309">getLogger</span><span style="color:#555">(</span>WebappExampleProcessApplication<span style="color:#555">.</span><span style="color:#309">class</span><span style="color:#555">.</span><span style="color:#309">getName</span><span style="color:#555">());</span>

    <span style="color:#069;font-weight:bold">public</span> <span style="color:#069;font-weight:bold">static</span> <span style="color:#078;font-weight:bold">void</span> <span style="color:#c0f">main</span><span style="color:#555">(</span>String<span style="color:#555">...</span> args<span style="color:#555">)</span> <span style="color:#555">{</span>
        SpringApplication<span style="color:#555">.</span><span style="color:#309">run</span><span style="color:#555">(</span>WebappExampleProcessApplication<span style="color:#555">.</span><span style="color:#309">class</span><span style="color:#555">,</span> args<span style="color:#555">);</span>
    <span style="color:#555">}</span>

    <span style="color:#99f">@Autowired</span>
    <span style="color:#069;font-weight:bold">private</span> RuntimeService runtimeService<span style="color:#555">;</span>

    <span style="color:#99f">@EventListener</span>
    <span style="color:#069;font-weight:bold">private</span> <span style="color:#078;font-weight:bold">void</span> <span style="color:#c0f">processPostDeploy</span><span style="color:#555">(</span>PostDeployEvent event<span style="color:#555">)</span> <span style="color:#555">{</span>
        runtimeService<span style="color:#555">.</span><span style="color:#309">startProcessInstanceByKey</span><span style="color:#555">(</span><span style="color:#c30">&#34;loan-approval&#34;</span><span style="color:#555">);</span>

        DecisionService decisionService <span style="color:#555">=</span> event<span style="color:#555">.</span><span style="color:#309">getProcessEngine</span><span style="color:#555">().</span><span style="color:#309">getDecisionService</span><span style="color:#555">();</span>

        VariableMap variables <span style="color:#555">=</span> Variables<span style="color:#555">.</span><span style="color:#309">createVariables</span><span style="color:#555">()</span>
                <span style="color:#555">.</span><span style="color:#309">putValue</span><span style="color:#555">(</span><span style="color:#c30">&#34;bmi&#34;</span><span style="color:#555">,</span> 20<span style="color:#555">.</span><span style="color:#309">0</span><span style="color:#555">);</span>

        DmnDecisionTableResult dmnDecisionTableResult <span style="color:#555">=</span> decisionService
                <span style="color:#555">.</span><span style="color:#309">evaluateDecisionTableByKey</span><span style="color:#555">(</span><span style="color:#c30">&#34;bmi-classification&#34;</span><span style="color:#555">,</span> variables<span style="color:#555">);</span>
        String result <span style="color:#555">=</span> dmnDecisionTableResult<span style="color:#555">.</span><span style="color:#309">getSingleEntry</span><span style="color:#555">();</span>

        LOGGER<span style="color:#555">.</span><span style="color:#309">log</span><span style="color:#555">(</span>Level<span style="color:#555">.</span><span style="color:#309">INFO</span><span style="color:#555">,</span> <span style="color:#c30">&#34;\n\nBMI Classification result is : {0}\n\n&#34;</span><span style="color:#555">,</span> result<span style="color:#555">);</span>
		
        <span style="color:#09f;font-style:italic">// &gt;&gt;&gt;&gt; 新增
</span><span style="color:#09f;font-style:italic"></span>        DmnDecisionTableResult suggestionResult <span style="color:#555">=</span> decisionService
                <span style="color:#555">.</span><span style="color:#309">evaluateDecisionTableByKey</span><span style="color:#555">(</span><span style="color:#c30">&#34;bmi-suggestion&#34;</span><span style="color:#555">,</span> variables<span style="color:#555">);</span>
        String suggestion <span style="color:#555">=</span> suggestionResult<span style="color:#555">.</span><span style="color:#309">getSingleEntry</span><span style="color:#555">();</span>

        LOGGER<span style="color:#555">.</span><span style="color:#309">log</span><span style="color:#555">(</span>Level<span style="color:#555">.</span><span style="color:#309">INFO</span><span style="color:#555">,</span> <span style="color:#c30">&#34;\n\nBMI Classification suggestion is : {0}\n\n&#34;</span><span style="color:#555">,</span> suggestion<span style="color:#555">);</span>
        <span style="color:#09f;font-style:italic">// &lt;&lt;&lt;&lt;
</span><span style="color:#09f;font-style:italic"></span>    <span style="color:#555">}</span>
<span style="color:#555">}</span>

</code></pre></div><p>重新编译并运行，可以看到 Spring Boot 输出：</p>
<pre><code>BMI Classification suggestion is : 没建议
</code></pre><p>表示执行成功</p>
<blockquote>
<p>到此第八部分结束，如果想直接获取到现在为止的进度，可以下载<a href="https://gitee.com/zoollcar/camunda-get-started-spring-boot-and-dmn/repository/archive/Step-8.zip" target="_blank">zip包</a>，或者使用如下命令</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">git clone https://gitee.com/zoollcar/camunda-get-started-spring-boot-and-dmn.git
git checkout -f Step-8
</code></pre></div></blockquote>
<blockquote>
<p>恭喜：你已经完成了快速入门的全部内容，想要继续学习，请前往<a href="https://docs.camunda.org/manual/latest/" target="_blank">Camunda 文档</a>.</p>
<p>也可以关注我的博客 <a href="/" target="_blank">http://shaochenfeng.com</a>，后续也会继续推出更多Camunda文档翻译或教程</p>
</blockquote>

  </article>
</div>
      
<div class="grow"></div>
<nav class="pagination-single">
  
    
      <a href="http://shaochenfeng.com/camunda/%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8%E4%BB%8B%E7%BB%8D/" title="快速入门介绍" class="pagination-single__left">
        <div class="pagination-single__icon">
          <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path fill="currentColor" d="M19 11H7.83l4.88-4.88c.39-.39.39-1.03 0-1.42-.39-.39-1.02-.39-1.41 0l-6.59 6.59c-.39.39-.39 1.02 0 1.41l6.59 6.59c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L7.83 13H19c.55 0 1-.45 1-1s-.45-1-1-1z"/></svg>
        </div>
        <div class="pagination-single__right-title">快速入门介绍</div>
      </a>
    
    <div class="grow"></div>
    
  
</nav>


      
    </article>
    
    <section id="list-side" class="r" data-dir="ltr">
      
        <div class="toc">
  <h6 class="toc__label">目录</h6>
  <div class="toc__body">
    <nav id="TableOfContents">
  <ul>
    <li><a href="#介绍">介绍</a></li>
    <li><a href="#创建-camunda-spring-boot-项目">创建 Camunda Spring Boot 项目</a></li>
    <li><a href="#部署bpmn20流程">部署BPMN2.0流程</a></li>
    <li><a href="#添加自定义表单">添加自定义表单</a></li>
    <li><a href="#在流程中调用-java-class">在流程中调用 JAVA Class</a></li>
    <li><a href="#在-java-中调用-dmn-决策">在 JAVA 中调用 DMN 决策</a></li>
    <li><a href="#从dmn决策表与drg决策图">从DMN决策表与DRG决策图</a></li>
  </ul>
</nav>
  </div>
</div>
      
    </section>

  </div>
</div>

<script>
  'use strict';
  
  function wrap(el, wrapper) {
    el.parentNode.insertBefore(wrapper, el);
    wrapper.appendChild(el);
  }

  (function () {
    var singleContentsElem = document.querySelector('.single__contents');
    singleContentsElem ? 
    singleContentsElem.querySelectorAll('pre > code').forEach(function(elem) {
      var dataLang = elem.getAttribute('data-lang');
      var dataLangWrapper = document.createElement('div');
      var code = null;
      var codeTitle = null;

      if (dataLang && dataLang.includes(':')) {
        code = dataLang.split(':')[0];
        codeTitle = dataLang.split(':')[1];

        dataLangWrapper.className = 'language-' + code;
        dataLangWrapper.setAttribute('data-lang', codeTitle);

        elem.className = 'language-' + code;
        elem.setAttribute('data-lang', codeTitle);
        elem.setAttribute('id', codeTitle);
      }

      if (!dataLang || codeTitle) {
        wrap(elem.parentNode, dataLangWrapper);
      }

    }) : null;
  })();
  


  
  
  var dollarCodeElem = document.querySelectorAll('div.language-\\$');
  var gtCodeElem = document.querySelectorAll('div.language-\\>');
  
  dollarCodeElem ?
  dollarCodeElem.forEach(function(elem) {
    var lnts = elem.parentNode.parentNode ? elem.parentNode.parentNode.querySelectorAll('.lnt') : null;
    lnts ? 
    lnts.forEach(function(lnt) {
      lnt.innerHTML = '$<br/>';
    }) : null;
  }) : null;

  gtCodeElem ?
  gtCodeElem.forEach(function(elem) {
    var lnts = elem.parentNode.parentNode ? elem.parentNode.parentNode.querySelectorAll('.lnt') : null;
    lnts ? 
    lnts.forEach(function(lnt) {
      lnt.innerHTML = '><br/>';
    }) : null;
  }) : null;
  
</script>




<script defer src="/js/helper/getParents.min.js"></script>

<script defer src="/js/helper/closest.min.js"></script>

<script defer src="/js/helper/prev.min.js"></script>

<script defer src="/js/helper/prop.min.js"></script>

<script defer src="/js/helper/fadeinout.min.js"></script>












<script>
  document.addEventListener('DOMContentLoaded', function () {
    'use strict';
    
    
    var tables = document.querySelectorAll('.single__contents > table');
    for (let i = 0; i < tables.length; i++) {
      var table = tables[i];
      var wrapper = document.createElement('div');
      wrapper.className = 'table-wrapper';
      table.parentElement.replaceChild(wrapper, table);
      wrapper.appendChild(table);
    }
    


    
    
    
    var lib = JSON.parse("null");

    if (lib && lib.includes('mermaid')) {
      var themeVariant = localStorage.getItem('theme') || 'light';

      if (themeVariant === "dark") {
        mermaid.initialize({ theme: 'dark' });
      } else {
        mermaid.initialize({ theme: 'default' });
      }
      
      var mermaids = [];
      [].push.apply(mermaids, document.getElementsByClassName('language-mermaid'));
      mermaids.forEach(function(elem) {
        var elemParentNode = elem.parentNode;

        if (elemParentNode !== document.body) {
          elemParentNode.parentNode.insertBefore(elem, elemParentNode);
          elemParentNode.parentNode.removeChild(elemParentNode);
        }

        var newElemWrapper = document.createElement('div');
        newElemWrapper.classList.add('mermaid');
        newElemWrapper.innerHTML = elem.innerHTML;
        elem.replaceWith(newElemWrapper);
      });
    }
    
    

    
    if (lib && lib.includes('katex')) {
      var mathElements = document.getElementsByClassName('math');
      var options = {
        delimiters: [
          { left: "$$", right: "$$", display: true },
          { left: "\\[", right: "\\]", display: true },
          { left: "$", right: "$", display: false },
          { left: "\\(", right: "\\)", display: false }
        ],
      };

      renderMathInElement(document.querySelector('.single__contents'), options);
    }
    


    
    if (lib && lib.includes('flowchartjs')) {
      
      var options = JSON.parse("{\"arrow-end\":\"block\",\"element-color\":\"black\",\"fill\":\"white\",\"flowstate\":{\"approved\":{\"fill\":\"#58C4A3\",\"font-size\":12,\"no-text\":\"n/a\",\"yes-text\":\"APPROVED\"},\"current\":{\"fill\":\"yellow\",\"font-color\":\"red\",\"font-weight\":\"bold\"},\"future\":{\"fill\":\"#FFFF99\"},\"invalid\":{\"fill\":\"#444444\"},\"past\":{\"fill\":\"#CCCCCC\",\"font-size\":12},\"rejected\":{\"fill\":\"#C45879\",\"font-size\":12,\"no-text\":\"REJECTED\",\"yes-text\":\"n/a\"},\"request\":{\"fill\":\"blue\"}},\"font-color\":\"black\",\"font-size\":14,\"line-color\":\"black\",\"line-length\":50,\"line-width\":3,\"no-text\":\"no\",\"scale\":1,\"symbols\":{\"end\":{\"class\":\"end-element\"},\"start\":{\"element-color\":\"green\",\"fill\":\"yellow\",\"font-color\":\"red\"}},\"text-margin\":10,\"x\":0,\"y\":0,\"yes-text\":\"yes\"}");
      var jsonContent = null;

      var flowchartPrefix = "language-flowchart";
      var index = 0;
      Array.prototype.forEach.call(document.querySelectorAll("[class^=" + flowchartPrefix + "]"), function(x){
          x.style.display = 'none'
          x.parentNode.style.backgroundColor = "transparent"
          jsonContent = x.innerText;

          var node0 = document.createElement('div');
          node0.id = 'flowchart' + index;
          x.parentNode.insertBefore(node0, x);

          var diagram = flowchart.parse(jsonContent);
          diagram.drawSVG("flowchart"+index, options);

          index +=1;
      });      
    }
    


    
    if (lib && lib.includes('chart')) {
      var borderColor = "#666";
      var bgColor = "#ddd";
      var borderWidth = 2;

      Chart.defaults.global.elements.rectangle.borderWidth = borderWidth;
      Chart.defaults.global.elements.rectangle.borderColor = borderColor;
      Chart.defaults.global.elements.rectangle.backgroundColor = bgColor;

      Chart.defaults.global.elements.line.borderWidth = borderWidth;
      Chart.defaults.global.elements.line.borderColor = borderColor;
      Chart.defaults.global.elements.line.backgroundColor = bgColor;

      Chart.defaults.global.elements.point.borderWidth = borderWidth;
      Chart.defaults.global.elements.point.borderColor = borderColor;
      Chart.defaults.global.elements.point.backgroundColor = bgColor;

      var chartPrefix = "language-chart";
      var index = 0;
      var jsonContent = null;

      Array.prototype.forEach.call(document.querySelectorAll("[class^=" + chartPrefix + "]"), function (x) {
        x.style.display = 'none'
        x.parentNode.style.backgroundColor = "transparent"
        jsonContent = x.innerText;
        var node0 = document.createElement('canvas');
        var source = null;
        node0.height = 200;
        node0.style.height = 200;
        node0.id = 'myChart' + index;
        source = JSON.parse(jsonContent);
        x.parentNode.insertBefore(node0, x);
        var ctx = document.getElementById('myChart' + index).getContext('2d');
        var myChart = new Chart(ctx, source);
        index += 1;
      });            
    }
    


    
    if (lib && lib.includes('viz')) {
      var vizPrefix = "language-viz-";
      Array.prototype.forEach.call(document.querySelectorAll("[class^=" + vizPrefix + "]"), function (x) {
        x.style.display = 'none'
        x.parentNode.style.backgroundColor = "transparent"
        var engine;
        x.getAttribute("class").split(" ").forEach(function (cls) {
          if (cls.startsWith(vizPrefix)) {
            engine = cls.substr(vizPrefix.length);
          }
        });
        var viz = new Viz();
        viz.renderSVGElement(x.innerText, { engine: engine })
          .then(function (element) {
            element.style.width = "100%";
            x.parentNode.insertBefore(element, x);
          })
      });
    }
    
    
  });
</script>

<script>
  var listSide = document.getElementById('list-side');
  var listMain = document.getElementById('list-main');
  var singleMenu = document.getElementById('single-menu');
  var switchElem = document.querySelector('.switch');
  var wideViewAsDefault = JSON.parse("null");
  
  enquire.register("screen and (max-width:1280px)", {
    match: function () {
      if (wideViewAsDefault) {
        singleMenu.className = 'l';  
        listMain.className = 'mr';
        listSide.className = 'hide';
      } else {
        singleMenu.className = 'l';
        listMain.className = 'm';
        listSide.className = 'r';
      }
    },
    unmatch: function () {
      if (wideViewAsDefault) {
        singleMenu.className = 'l';
        listMain.className = 'mr';
        listSide.className = 'hide';
      } else {
        listSide.className = 'r';
        listMain.className = 'm';
        singleMenu.className = 'l';
      }
    },
  }).register("screen and (max-width:960px)", {
    match: function () {
      singleMenu.className = 'l';
      listMain.className = 'mr';
      listSide.className = 'hide';
      switchElem.className = 'hide';
    },
    unmatch: function () {
      if (wideViewAsDefault) {
        singleMenu.className = 'l';
        listMain.className = 'mr';
        listSide.className = 'hide';
      } else {
        singleMenu.className = 'l';
        listMain.className = 'm';
        listSide.className = 'r';
      }
      switchElem.className = 'switch';
    },
  }).register("screen and (max-width:600px)", {
    match: function () {
      listSide.className = 'hide';
      listMain.className = 'lmr';
      singleMenu.className = 'hide';
      switchElem.className = 'hide';
    },
    unmatch: function () {
      listSide.className = 'hide';
      listMain.className = 'mr';
      singleMenu.className = 'l';
      switchElem.className = 'hide';
    },
  });
</script>

        
<div class="bot">
  <footer class="footer">
    <div class="divider">
      <div class="lmr">
        
          <p class="caption">
            <a href="https://beian.miit.gov.cn/" target="_blank">冀ICP备18002899号</a>    ©2021, All Rights Reserved
          </p>
          
        
      </div>
    </div>
  </footer>
</div>

    </div>

</body>

</html>